-
Notifications
You must be signed in to change notification settings - Fork 239
Add new shapeExamples trait that communicates and enforces allowed and disallowed values #2851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add new shapeExamples trait that communicates and enforces allowed and disallowed values #2851
Conversation
…d disallowed values
.changes/next-release/feature-0dad6fe920f7dc053e14bed2d43b2e553a2f142a.json
Show resolved
Hide resolved
…3a2f142a.json Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
| } | ||
| } | ||
|
|
||
| private static final class ErrorsFileValidationEventFormatter implements ValidationEventFormatter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated implementation here to make it easier to iterate on error files -- the previous implementation would output the extra file location information and hints if they exist, which are explicitly omitted from the errors file normally.
You can now copy+paste directly from the failure message in the test result into the errors file.
| if (value.isNullNode()) { | ||
|
|
||
| if (!value.isNullNode()) { | ||
| model.getShape(shape.getTarget()).ifPresent(target -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally traversing into the shape when the value was null pretty much guaranteed that an error would be reported -- generally of the form "<string, number, object> was expected but value was null" (not exact wording).
Since is the memberShape method, this only affects aggregate types which have an explicit null value as opposed to the member being omitted.
| allowed: ShapeExampleList | ||
| disallowed: ShapeExampleList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
| allowed: ShapeExampleList | |
| disallowed: ShapeExampleList | |
| valid: ShapeExampleList | |
| invalid: ShapeExampleList |
AFAICT "valid" appears a whole lot more in the spec/documentation than "allowed"
Background
@shapeExamplestrait which defines the set of allowed and disallowed values for a given shape.NodeValidationVisitorto be more accurate in some less-commonly used casesShapeExamplesTraitValidatorimplementation which verifies that:@pattern-based constrained valuesTesting
Links
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.