amazon-ion / ion-schema-rust

Rust implementation of Ion Schema
https://amazon-ion.github.io/ion-schema/sandbox
Apache License 2.0
13 stars 6 forks source link

adds implementation of `valid_values` constraint #92

Closed desaikd closed 2 years ago

desaikd commented 2 years ago

Issue #9 #10

Description of changes: This PR works on adding implementation of valid_values constraint.

Grammar:

<VALID_VALUES> ::= valid_values: [ <VALUE>... ]
                 | valid_values: <RANGE<NUMBER>>
                 | valid_values: <RANGE<TIMESTAMP>>

Ion Schema specification: https://amzn.github.io/ion-schema/docs/spec.html#valid_values

List of changes:

Tests: added unit tests for valid_values implementation.

Question: Should there be a Violation returned when an OwnedElement with annotation is passed to validate with valid_values constraint or silently ignore the annotation? (Note: current implementation ignores the annotation)

popematt commented 2 years ago

Should there be a Violation returned when an OwnedElement with annotation is passed to validate with valid_values constraint or silently ignore the annotation? (Note: current implementation ignores the annotation)

No. The current implementation is correct. This constraint is intended to compare the value, excluding annotations. In fact, it is even illegal to use annotations on the valid values arguments, with the exception of ranges (e.g. valid_values: [foo::1] is illegal).

Good question, though. 👍🏼