Support merging types with multiple regex validations (allOf).#1008
Merged
Conversation
ahl
approved these changes
May 15, 2026
| Some(unhandled) => { | ||
| info!("treating a string format '{}' as a String", unhandled); | ||
| Ok((TypeEntryDetails::String.into(), metadata)) | ||
| // Apply constaints when there is no format or the format isn't |
Collaborator
There was a problem hiding this comment.
I simplified this rather than duplicating the code.
| NonAsciiChars::add(&mut type_space); | ||
| UnknownFormat::add(&mut type_space); | ||
| ipnetwork::IpNetwork::add(&mut type_space); | ||
| TriplePattern::add(&mut type_space); |
Collaborator
There was a problem hiding this comment.
used a more consistent pattern here.
Contributor
Author
those changes lgtm, thanks! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I tried running Typify on a schema that had an
allOfdeclaration:but this resulted in an error:
Message: not implemented: merging distinct patterns is impracticalThis PR handles the case of multiple regex validation patterns by chaining them with lookaheads.
Consider the test code in this PR at
typify-impl/tests/all_of.json:{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "TriplePattern": { "allOf": [ { "type": "string", "pattern": "^[a-z].+$", "format": "custom-id" }, { "type": "string", "pattern": "^.{4,8}$" }, { "type": "string", "pattern": ".+[a-z]$" } ] } } }Regex validation for this will now result in:
This adds a new test
all_ofintypify-test/src/main.rsthat verifies this functionality works as expected. It uses thatall_of.json, which is also used for an integration test intestify-impl.Fun fact, the original schema I was trying to process was the NIST OSCAL schema at https://github.com/usnistgov/OSCAL/releases/download/v1.2.2/oscal_catalog_schema.json. I am able to successfully run Typify on that schema with this PR. The pattern for that
EmailAddressDatatypetype results in: