-
Notifications
You must be signed in to change notification settings - Fork 218
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
Add warning for pattern traits missing ^ or $ anchors #1141
Conversation
smithy-aws-protocol-tests/model/awsJson1_1/services/machinelearning.smithy
Show resolved
Hide resolved
.../src/main/java/software/amazon/smithy/model/validation/validators/PatternTraitValidator.java
Outdated
Show resolved
Hide resolved
smithy-model/src/test/resources/software/amazon/smithy/model/validation/node-validator.json
Show resolved
Hide resolved
...ources/software/amazon/smithy/model/errorfiles/validators/http-uri-conflict-validator.errors
Outdated
Show resolved
Hide resolved
...esources/software/amazon/smithy/model/errorfiles/validators/http-uri-conflict-validator.json
Outdated
Show resolved
Hide resolved
...esources/software/amazon/smithy/model/errorfiles/validators/http-uri-conflict-validator.json
Outdated
Show resolved
Hide resolved
25766d2
to
3dd2706
Compare
.../src/main/java/software/amazon/smithy/model/validation/validators/PatternTraitValidator.java
Outdated
Show resolved
Hide resolved
.../src/main/java/software/amazon/smithy/model/validation/validators/PatternTraitValidator.java
Outdated
Show resolved
Hide resolved
...esources/software/amazon/smithy/model/errorfiles/validators/http-uri-conflict-validator.json
Outdated
Show resolved
Hide resolved
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.
It might be nice to elaborate on the warning more with why they should anchor expressions. For example:
[WARNING] ns.foo#Structure$WithoutAnchorsMember: A pattern trait is applied without a leading '^' and trailing '$', meaning only part of the string must match the regular expression. Explicitly anchoring regular expressions is preferable because it is more restrictive by default and does not require modelers to understand that Smithy patterns are not automatically anchored. | PatternTrait
The pattern trait does not implicitly add a leading ^ or trailing $ to match an entire string. If customer thinks the anchors are implicitly added they may allow more values than expected. This WARNING will help customers identify if they unintentionally forgot the anchors.
The pattern trait does not implicitly add a leading ^ or trailing $ to
match an entire string. If customer thinks the anchors are implicitly
added they may allow more values than expected. This WARNING will help
customers identify if they unintentionally forgot the anchors.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.