diff --git a/examples/Org.OData.Validation.V1.PostCondition-sample.json b/examples/Org.OData.Validation.V1.PostCondition-sample.json new file mode 100644 index 00000000..01125669 --- /dev/null +++ b/examples/Org.OData.Validation.V1.PostCondition-sample.json @@ -0,0 +1,47 @@ +{ + "$Version": "4.0", + "$Reference": { + "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Validation.V1.json": { + "$Include": [ + { + "$Namespace": "Org.OData.Validation.V1", + "$Alias": "Validation" + } + ] + } + }, + "postcondition.sample": { + "WorkerTimeSheet": { + "$Kind": "EntityType", + "ClockInDateTime": { + "$Type": "Edm.DateTimeOffset", + "$Nullable": true, + "$Precision": 0 + }, + "ClockOutDateTime": { + "$Type": "Edm.DateTimeOffset", + "$Nullable": true, + "$Precision": 0 + } + }, + "$Annotations": { + "postcondition.sample.WorkerTimeSheet": { + "@Validation.PostCondition#overtime": { + "$Gt": [ + { + "$Sub": [ + { + "$Path": "ClockOutDateTime" + }, + { + "$Path": "ClockInDateTime" + } + ] + }, + "PT8H" + ] + } + } + } + } +} \ No newline at end of file diff --git a/examples/Org.OData.Validation.V1.PostCondition-sample.xml b/examples/Org.OData.Validation.V1.PostCondition-sample.xml new file mode 100644 index 00000000..e10c00fe --- /dev/null +++ b/examples/Org.OData.Validation.V1.PostCondition-sample.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + ClockOutDateTime + ClockInDateTime + + PT8H + + + + + + diff --git a/vocabularies/Org.OData.Validation.V1.json b/vocabularies/Org.OData.Validation.V1.json index 6b401cc1..13e7de85 100644 --- a/vocabularies/Org.OData.Validation.V1.json +++ b/vocabularies/Org.OData.Validation.V1.json @@ -128,6 +128,19 @@ "@Core.Description": "Value MUST be a dynamic expression that evaluates to true if and only if the constraint is fulfilled" } }, + "PostCondition": { + "$Kind": "Term", + "$Type": "Edm.PrimitiveType", + "$AppliesTo": [ + "Property", + "NavigationProperty", + "Parameter", + "EntityType", + "ComplexType" + ], + "@Core.Description": "Condition that clients can demand for the after-image of a data modification request", + "@Core.LongDescription": "The value is given as a dynamic expression in the metadata, optionally with a qualifier.\n If the payload of a data modification request provides an instance annotation\n with this term and the same qualifier, the request MUST fail if the provided value\n does not match the dynamically expressed value in the modified data.
\n See [this example](../examples/Org.OData.Validation.V1.PostCondition-sample.xml).\n To avoid posting overtime, clients include\n `{\"@Validation.PostCondition#overtime\": false}` in their insert requests." + }, "ItemsOf": { "$Kind": "Term", "$Collection": true, diff --git a/vocabularies/Org.OData.Validation.V1.md b/vocabularies/Org.OData.Validation.V1.md index 7b330ff2..00c7bfff 100644 --- a/vocabularies/Org.OData.Validation.V1.md +++ b/vocabularies/Org.OData.Validation.V1.md @@ -15,13 +15,14 @@ Term|Type|Description [AllowedValues](Org.OData.Validation.V1.xml#L94)|\[[AllowedValue](#AllowedValue)\]|A collection of valid values for the annotated property, parameter, or type definition [MultipleOf](Org.OData.Validation.V1.xml#L108)|Decimal|The value of the annotated property, parameter, or term must be an integer multiple of this positive value. For temporal types, the value is measured in seconds. [Constraint](Org.OData.Validation.V1.xml#L112)|[ConstraintType](#ConstraintType)|Condition that the annotation target has to fulfill -[ItemsOf](Org.OData.Validation.V1.xml#L125)|\[[ItemsOfType](#ItemsOfType)\]|A list of constraints describing that entities related via one navigation property MUST also be related via another, collection-valued navigation property. The same `path` value MUST NOT occur more than once.
Example: entity type `Customer` has navigation properties `AllOrders`, `OpenOrders`, and `ClosedOrders`. The term allows to express that items of `OpenOrders` and `ClosedOrders` are also items of the `AllOrders` navigation property, even though they are defined in an `Orders` entity set. -[OpenPropertyTypeConstraint](Org.OData.Validation.V1.xml#L143)|\[[SingleOrCollectionType](#SingleOrCollectionType)\]|Dynamic properties added to the annotated open structured type are restricted to the listed types. -[DerivedTypeConstraint](Org.OData.Validation.V1.xml#L147)|\[[SingleOrCollectionType](#SingleOrCollectionType)\]|Values are restricted to types that are both identical to or derived from the declared type and a type listed in this collection.
This allows restricting values to certain sub-trees of an inheritance hierarchy, including hierarchies starting at the [Built-In Abstract Types](https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html#sec_BuiltInAbstractTypes). Types listed in this collection are ignored if they are not derived from the declared type of the annotated model element or would not be allowed as declared type of the annotated model element.
When applied to a collection-valued element, this annotation specifies the types allowed for members of the collection without mentioning the `Collection()` wrapper. The SingleOrCollectionType may only include the `Collection()` wrapper if the annotation is applied to an element with declared type `Edm.Untyped`. -[AllowedTerms](Org.OData.Validation.V1.xml#L166)|\[[QualifiedTermName](Org.OData.Core.V1.md#QualifiedTermName)\]|Annotate a term of type Edm.AnnotationPath, or a property of type Edm.AnnotationPath that is used within a structured term, to restrict the terms that can be targeted by the path.
The annotation path expression is intended to end in a path segment with one of the listed terms. For forward compatibility, clients should be prepared for the annotation to reference terms besides those listed. -[ApplicableTerms](Org.OData.Validation.V1.xml#L172)|\[[QualifiedTermName](Org.OData.Core.V1.md#QualifiedTermName)\]|Names of specific terms that are applicable and may be applied in the current context. This annotation does not restrict the use of other terms. -[MaxItems](Org.OData.Validation.V1.xml#L176)|Int64|The annotated collection must have at most the specified number of items. -[MinItems](Org.OData.Validation.V1.xml#L180)|Int64|The annotated collection must have at least the specified number of items. +[PostCondition](Org.OData.Validation.V1.xml#L125)|PrimitiveType|Condition that clients can demand for the after-image of a data modification request
The value is given as a dynamic expression in the metadata, optionally with a qualifier. If the payload of a data modification request provides an instance annotation with this term and the same qualifier, the request MUST fail if the provided value does not match the dynamically expressed value in the modified data.
See [this example](../examples/Org.OData.Validation.V1.PostCondition-sample.xml). To avoid posting overtime, clients include `{"@Validation.PostCondition#overtime": false}` in their insert requests. +[ItemsOf](Org.OData.Validation.V1.xml#L138)|\[[ItemsOfType](#ItemsOfType)\]|A list of constraints describing that entities related via one navigation property MUST also be related via another, collection-valued navigation property. The same `path` value MUST NOT occur more than once.
Example: entity type `Customer` has navigation properties `AllOrders`, `OpenOrders`, and `ClosedOrders`. The term allows to express that items of `OpenOrders` and `ClosedOrders` are also items of the `AllOrders` navigation property, even though they are defined in an `Orders` entity set. +[OpenPropertyTypeConstraint](Org.OData.Validation.V1.xml#L156)|\[[SingleOrCollectionType](#SingleOrCollectionType)\]|Dynamic properties added to the annotated open structured type are restricted to the listed types. +[DerivedTypeConstraint](Org.OData.Validation.V1.xml#L160)|\[[SingleOrCollectionType](#SingleOrCollectionType)\]|Values are restricted to types that are both identical to or derived from the declared type and a type listed in this collection.
This allows restricting values to certain sub-trees of an inheritance hierarchy, including hierarchies starting at the [Built-In Abstract Types](https://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html#sec_BuiltInAbstractTypes). Types listed in this collection are ignored if they are not derived from the declared type of the annotated model element or would not be allowed as declared type of the annotated model element.
When applied to a collection-valued element, this annotation specifies the types allowed for members of the collection without mentioning the `Collection()` wrapper. The SingleOrCollectionType may only include the `Collection()` wrapper if the annotation is applied to an element with declared type `Edm.Untyped`. +[AllowedTerms](Org.OData.Validation.V1.xml#L179)|\[[QualifiedTermName](Org.OData.Core.V1.md#QualifiedTermName)\]|Annotate a term of type Edm.AnnotationPath, or a property of type Edm.AnnotationPath that is used within a structured term, to restrict the terms that can be targeted by the path.
The annotation path expression is intended to end in a path segment with one of the listed terms. For forward compatibility, clients should be prepared for the annotation to reference terms besides those listed. +[ApplicableTerms](Org.OData.Validation.V1.xml#L185)|\[[QualifiedTermName](Org.OData.Core.V1.md#QualifiedTermName)\]|Names of specific terms that are applicable and may be applied in the current context. This annotation does not restrict the use of other terms. +[MaxItems](Org.OData.Validation.V1.xml#L189)|Int64|The annotated collection must have at most the specified number of items. +[MinItems](Org.OData.Validation.V1.xml#L193)|Int64|The annotated collection must have at least the specified number of items. ## [AllowedValue](Org.OData.Validation.V1.xml#L97) @@ -45,16 +46,16 @@ Property|Type|Description [Condition](Org.OData.Validation.V1.xml#L120)|Boolean|Value MUST be a dynamic expression that evaluates to true if and only if the constraint is fulfilled -## [ItemsOfType](Org.OData.Validation.V1.xml#L133) +## [ItemsOfType](Org.OData.Validation.V1.xml#L146) Entities related via the single- or collection-valued navigation property identified by `path` are also related via the collection-valued navigation property identified by `target`. Property|Type|Description :-------|:---|:---------- -[path](Org.OData.Validation.V1.xml#L135)|NavigationPropertyPath|A path to a single- or collection-valued navigation property -[target](Org.OData.Validation.V1.xml#L138)|NavigationPropertyPath|A path to a collection-valued navigation property +[path](Org.OData.Validation.V1.xml#L148)|NavigationPropertyPath|A path to a single- or collection-valued navigation property +[target](Org.OData.Validation.V1.xml#L151)|NavigationPropertyPath|A path to a collection-valued navigation property -## [SingleOrCollectionType](Org.OData.Validation.V1.xml#L162) +## [SingleOrCollectionType](Org.OData.Validation.V1.xml#L175) **Type:** String The qualified name of a type in scope, optionally wrapped in `Collection()` to denote a collection of instances of the type diff --git a/vocabularies/Org.OData.Validation.V1.xml b/vocabularies/Org.OData.Validation.V1.xml index e100e4aa..8cc22dfb 100644 --- a/vocabularies/Org.OData.Validation.V1.xml +++ b/vocabularies/Org.OData.Validation.V1.xml @@ -122,6 +122,19 @@ + + + + The value is given as a dynamic expression in the metadata, optionally with a qualifier. + If the payload of a data modification request provides an instance annotation + with this term and the same qualifier, the request MUST fail if the provided value + does not match the dynamically expressed value in the modified data.<br> + See [this example](../examples/Org.OData.Validation.V1.PostCondition-sample.xml). + To avoid posting overtime, clients include + `{"@Validation.PostCondition#overtime": false}` in their insert requests. + + +