Skip to content
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

[Feature] Support for JSON minimum , maximum, exclusiveMinimum, and exclusiveMaximum #1023

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

hudson-ai
Copy link
Collaborator

@hudson-ai hudson-ai commented Sep 13, 2024

JSON support for integer and float bounds.

Closes #1019 (thanks for the code @mmoskal!)

@codecov-commenter
Copy link

codecov-commenter commented Sep 16, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 98.06763% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.02%. Comparing base (af63e6d) to head (284a673).

Files with missing lines Patch % Lines
guidance/library/_regex_utils.py 97.54% 4 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1023      +/-   ##
==========================================
- Coverage   70.26%   63.02%   -7.25%     
==========================================
  Files          62       63       +1     
  Lines        4470     4668     +198     
==========================================
- Hits         3141     2942     -199     
- Misses       1329     1726     +397     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hudson-ai hudson-ai changed the title [WIP] [Feature] Support for JSON minimum , maximum, exclusiveMinimum, and exclusiveMaximum [Feature] Support for JSON minimum , maximum, exclusiveMinimum, and exclusiveMaximum Sep 19, 2024
@hudson-ai
Copy link
Collaborator Author

Note: we have one xfail here due to the fact that JSON apparently allows trailing .00000... on integers. We could add support for this in the future, but I don't really see a reason to (as doing so doesn't really add any expressive power to a model). Keeping the xfail around as a little piece of "documentation".

Ready for review.

@hudson-ai
Copy link
Collaborator Author

Another note: JSON Schema Draft4 has a slightly different convention around exclusiveMinimum/exclusiveMaximum (where they are treated as bools). We may want to allow schemas using this convention, just because I still see a lot of Draft4 in the wild.

Currently, our Draft202012 validator will reject these schemas, so we should be safe not to handle that case internally. Allowing Draft4 might open a bit of a can of worms, so I want to punt on that for at least a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support for minimum/maximum in JSON schemas
3 participants