Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-940

Define a validation term for valid values

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_ERRATA03
    • Fix Version/s: V4.01_WD01
    • Component/s: Vocabularies
    • Labels:
      None
    • Environment:

      [Proposed]

    • Proposal:
      Hide

      Define a new term for "AllowedValues", as part of the Validation vocabulary:

      <Term Name="AllowedValues" Type="Collection(Validation.AllowedValue)">
      <Annotation Term="Core.Description"
      String="A collection of valid values for the annotated property, parameter, or type definition" />
      </Term>

      <ComplexType Name="AllowedValue">
      <Property Name="Value" Type="Edm.PrimitiveType">
      <Annotation Term="Core.Description" String="An allowed value for the property, parameter, or type definition" />
      </Property>
      </ComplexType>

      That could then be used, for example:

      <TypeDefinition Name="Weekdays" UnderlyingType="Edm.String">
      <Annotation Term="Validation.AllowedValues">
      <Collection>
      <Record>
      <PropertyValue Property="Value" String="Monday" />
      </Record>
      <Record>
      <PropertyValue Property="Value" String="Tuesday" />
      </Record>
      <Record>
      <PropertyValue Property="Value" String="Wednesday" />
      </Record>
      <Record>
      <PropertyValue Property="Value" String="Thursday" />
      </Record>
      <Record>
      <PropertyValue Property="Value" String="Friday" />
      </Record>
      </Collection>
      </Annotation>
      </TypeDefinition>

      Show
      Define a new term for "AllowedValues", as part of the Validation vocabulary: <Term Name="AllowedValues" Type="Collection(Validation.AllowedValue)"> <Annotation Term="Core.Description" String="A collection of valid values for the annotated property, parameter, or type definition" /> </Term> <ComplexType Name="AllowedValue"> <Property Name="Value" Type="Edm.PrimitiveType"> <Annotation Term="Core.Description" String="An allowed value for the property, parameter, or type definition" /> </Property> </ComplexType> That could then be used, for example: <TypeDefinition Name="Weekdays" UnderlyingType="Edm.String"> <Annotation Term="Validation.AllowedValues"> <Collection> <Record> <PropertyValue Property="Value" String="Monday" /> </Record> <Record> <PropertyValue Property="Value" String="Tuesday" /> </Record> <Record> <PropertyValue Property="Value" String="Wednesday" /> </Record> <Record> <PropertyValue Property="Value" String="Thursday" /> </Record> <Record> <PropertyValue Property="Value" String="Friday" /> </Record> </Collection> </Annotation> </TypeDefinition>
    • Resolution:
      Show
      https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/4.01%20spec/vocabularies/Org.OData.Capabilities.V1.xml https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/4.01%20spec/vocabularies/Org.OData.Core.V1.xml https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/4.01%20spec/vocabularies/Org.OData.Validation.V1.xml

      Description

      ODATA-849 proposes allowing enumerations to extend other enumerations.
      ODATA-494 similarly proposes allowing enumerations to derive from other enumerations.
      ODATA-874 proposes allowing string as an underlying type

      We have also had requests to support enumerations that don't conform to the rules for simple identifiers (i.e., they may have spaces, dashes, etc. in the names)

      All of these are good suggestions, but they don't play well with enumerations in programming languages.

      As an alternative to trying to introduce rules that don't work well with programming languages, we could simply extend the validation vocabulary with a term that could be applied to any property in order to limit the domain of valid values for that property, or defined as a type definition such that any property that used that type definition would have the constraint.

      The semantics of this new construct would be clear up front that it could change over time, so applications would need to account for unexpected values.

      This could be used where an enumeration was not appropriate, for example:
      1) Where the allowable values needed to change over time
      2) Where the allowable values needed to extend an existing allowable values
      3) Where the allowable values were not (all) strings
      4) Where the allowable values did not satisfy simple identifier rules

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mikep Michael Pizzo (Inactive)
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: