Skip to content

[REFACTOR](core) Convert StrippedConstraint to PatternConstraint subclass#466

Merged
Victor Schappert (vcschapp) merged 1 commit intodevfrom
stripped-constraint-pattern
Mar 11, 2026
Merged

[REFACTOR](core) Convert StrippedConstraint to PatternConstraint subclass#466
Victor Schappert (vcschapp) merged 1 commit intodevfrom
stripped-constraint-pattern

Conversation

@sethfitz
Copy link
Copy Markdown
Collaborator

StrippedConstraint now extends PatternConstraint, using the same constructor as every other concrete constraint. Custom validate() and __get_pydantic_json_schema__() eliminated. Codegen extracts the regex via constraint.pattern.pattern.

Uses \Z (absolute end-of-string) instead of $ because Python's $ matches before a trailing \n, which would let strings like "hello\n" pass validation. JSON schema emission swaps \Z back to $ since ECMA regex treats $ as absolute end-of-string.

StrippedConstraint now extends PatternConstraint, using the same
constructor as every other concrete constraint. Custom validate()
and __get_pydantic_json_schema__() eliminated.

Uses \Z (absolute end-of-string) instead of $ because Python's $
matches before a trailing \n. JSON schema emission swaps \Z back
to $ since ECMA regex treats $ as absolute end-of-string.

Signed-off-by: Seth Fitzsimmons <sethfitz@amazon.com>
@vcschapp Victor Schappert (vcschapp) merged commit 7162a0d into dev Mar 11, 2026
5 of 7 checks passed
@vcschapp Victor Schappert (vcschapp) deleted the stripped-constraint-pattern branch March 11, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants