Add new shapeExamples trait that communicates and enforces allowed and disallowed values#2851
Add new shapeExamples trait that communicates and enforces allowed and disallowed values#2851brandondahler wants to merge 3 commits intosmithy-lang:mainfrom
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.
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.
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.
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.