-
Notifications
You must be signed in to change notification settings - Fork 211
Implement @pattern
on string
shapes
#1998
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
Merged
Merged
Changes from 59 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
c45d0b0
Refactor `ConstrainedStringGenerator` to extract length checking
jjant bc29310
Extract `TryFrom` rendering into its own function
jjant 44495b9
Extract `ConstraintViolation` definition to separate function
jjant e140694
Add pattern check mock for `@pattern` trait
jjant ae21ce7
Add `regex` to list of server dependencies
jjant 4c6384d
Use real regex check in `check_pattern`
jjant c3e9659
Add `@pattern` to traits that make `string` shapes directly constrained
jjant b950c19
Remove unsupported validation for `@pattern` on strings
jjant b9206bf
Fix test cases in `ConstraintsTest`
jjant 1f3d763
Remove test disallowing `@pattern` on strings
jjant 838485b
Add first test case for `@pattern` on strings
jjant 1aa2573
Fix codegen in `ConstraintViolation::as_validation_exception_field`
jjant d4de234
Use `OnceCell` to store `@pattern`'s regex
jjant be24407
Tidy up `ConstrainedStringGenerator` to work with many constraints
jjant 77637fd
Rename `handleTrait` -> `fromTrait` and make it a static method
jjant aae0b75
Add docs for `ConstraintViolation` variants
jjant 116e9de
Fix unescaped slashes in regexes
jjant 55df743
Quick hack to get tests compiling
jjant 67863ca
Fix `sensitive_string_display_implementation` test
jjant b4331cc
Merge branch 'main' into jjant/implement-length-trait-on-strings
jjant 96ea2c7
Use new fn name: `asType` -> `toType`
jjant 275e2a8
Refactor `ConstrainedStringGenerator` to not pass in `constraints`
jjant 4ffd550
Add `@pattern` test
jjant 0797f4d
Use `Lazy` instead of `OnceCell`
jjant 22fd18f
Store `&'static str` in `Pattern` error instead of `String`
jjant 65139bd
Move `TraitInfo` to the bottom
jjant d26a877
Extract branches in `TraitInfo.fromTrait` into separate functions
jjant 0d7bbee
Add `PatternTrait.validationErrorMessage`
jjant 85ddc4c
Add more tests for `@pattern`
jjant e8b47a2
Merge branch 'main' into jjant/implement-length-trait-on-strings
jjant a6ad449
Add entry to `CHANGELOG.next.toml`
jjant 8ade3a1
Fix a `@length` + `@pattern` test case
jjant 961e3af
Remove unused binding in `ConstrainedStringGeneratorTest`
jjant 8a1f73f
Remove calls to `trimIndent`
jjant 1f02303
Use raw Rust strings instead of `escapedPattern`
jjant dcd2528
Require `regex 1.5.5` instead of `1.7.0`
jjant d90f447
Use `Writable`s in `TraitInfo`
jjant 78d6512
Use single `rust` call for `impl $name` block
jjant 4234b6d
Move `supportedStringConstraintTraits` to `Constraints.kt`
jjant abaf910
Fix error message mentioning wrong `ignoreUnsupportedConstraintTraits…
jjant 46b126b
Fix usage of `:W` in `rustTemplate` and raw Rust strings
jjant d551168
Use shorthand form for `PatternTrait.validationErrorMessage`
jjant 76e5984
Fix protocol tests by adjusting the validation message
jjant 227ddaf
Add uses of `@pattern` in `constraints.smithy` model
jjant 147af6b
Merge branch 'main' into jjant/implement-length-trait-on-strings
jjant e89850f
Fix broken `RestJsonMalformedPatternReDOSString` test
jjant 995bf0f
Move `TraitInfo` to its own module and separate string-specific details
jjant 3e45b9e
Update codegen-core/common-test-models/constraints.smithy
jjant 309423f
Fix nits in `constraints.smithy`
jjant 7a95fe2
Add license to `TraitInfo.kt`
jjant 7f5e68f
Merge branch 'jjant/implement-length-trait-on-strings' of github.com:…
jjant bbb1b81
Make `StringTraitInfo.fromTrait` not return a nullable
jjant fdcd2b7
Remove overzealous formatting
jjant 4a06c77
Add some padding to json in `fixRestJsonMalformedPatternReDOSString`
jjant 750e49d
Add `compile_regex` function for `@pattern` strings
jjant 11ee326
Add helpful error message when regexes fail to compile
jjant cb4d4ee
Add missing coverage in `constraints.smithy`
jjant be4a85a
Fix examples in `constraints.smithy`
jjant 105112a
Fix failing test
jjant 0d2b6b6
Combine writables in `ConstrainedStringGenerator`
jjant 3848d34
Fix uses of `Writable.join`
jjant fdf88b0
Use `expect` over `unwrap_or_else`
jjant 53cf34c
Use `once_cell::sync::Lazy` over `once_cell::sync::OnceCell`
jjant 7a2576c
Merge branch 'main' into jjant/implement-length-trait-on-strings
jjant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...n/software/amazon/smithy/rust/codegen/server/smithy/PatternTraitValidationErrorMessage.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.server.smithy | ||
|
||
import software.amazon.smithy.model.traits.PatternTrait | ||
|
||
@Suppress("UnusedReceiverParameter") | ||
fun PatternTrait.validationErrorMessage(): String = | ||
"Value {} at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.