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

Fix the error message when using exclusiveMinimum/exclusiveMaximum #15

Merged
merged 1 commit into from
Mar 3, 2021

Conversation

yotsuya
Copy link
Contributor

@yotsuya yotsuya commented Feb 25, 2021

Hello, Thank you for this awesome library.

I found that the error message returned by validateToJSON is broken when using the exclusiveMinimum/exclusiveMaximum keywords.

>>> -- exclusiveMinimum: false
>>> newtype Ge1 = Ge1 Integer deriving Generic
>>> instance ToJSON Ge1 where toJSON (Ge1 n) = toJSON n
>>> instance ToSchema Ge1 where declareNamedSchema proxy = genericDeclareNamedSchema defaultSchemaOptions proxy & mapped.minimum_ ?~ 1
>>> validateToJSON (Ge1 0)
["value 0.0 falls below minimum (should be >=1.0)"] -- Good

>>> -- exclusiveMinimum: true
>>> newtype Gt1 = Gt1 Integer deriving Generic
>>> instance ToJSON Gt1 where toJSON (Gt1 n) = toJSON n
>>> instance ToSchema Gt1 where declareNamedSchema proxy = genericDeclareNamedSchema defaultSchemaOptions proxy & mapped.minimum_ ?~ 1 & mapped.exclusiveMinimum ?~ True
>>> validateToJSON (Gt1 0)
["value 0.0 falls below minimum (should be >"] -- Missing after '>'

Hope this helps.

@maksbotan
Copy link
Collaborator

Hi! Thanks for the fix!

CI failure is not related to your changes. I've pushed the fix for it to master, can you please rebase or merge your branch on master?

@yotsuya
Copy link
Contributor Author

yotsuya commented Feb 26, 2021

I've rebased and pushed.

@maksbotan maksbotan merged commit a2d1509 into biocad:master Mar 3, 2021
@maksbotan
Copy link
Collaborator

Thanks! Sorry for the delay.

@maksbotan
Copy link
Collaborator

@yotsuya yotsuya deleted the fix-validation-error-message branch March 4, 2021 06:50
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.

None yet

2 participants