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

Define the multipleOfPrecision option for ajv to handle javascript number precision #1997

Closed
wants to merge 1 commit into from

Conversation

DyspC
Copy link
Contributor

@DyspC DyspC commented Feb 23, 2022

Summary

Prism had trouble with the OAI multipleOf number constraint because the default ajv validation does not behave properly with non integer multipliers cf. https://github.com/ajv-validator/ajv/blob/master/lib/vocabularies/validation/multipleOf.ts

Eg: -4.02 multipleOf 0.01 was rejected because JS says -4.02 / 0.01 = -401.99999999999994

This PR adds the AJV option to handle an error margin (1/1000th at the moment)

Checklist

  • The basics
    • I tested these changes manually in my local or dev environment
  • Tests
    • Added or updated
    • N/A
  • Event Tracking
    • I added event tracking and followed the event tracking guidelines
    • N/A
  • Error Reporting
    • I reported errors and followed the error reporting guidelines
    • N/A

Context

ajv-validator/ajv#84
ajv-validator/ajv#652

@DyspC DyspC requested a review from a team as a code owner February 23, 2022 15:17
@DyspC DyspC requested review from brendarearden and removed request for a team February 23, 2022 15:17
@chohmann
Copy link
Contributor

@DyspC can you add a few test cases to cover this functionality?

@chohmann
Copy link
Contributor

chohmann commented Jun 3, 2022

@DyspC we really appreciate the PR! Since we haven't heard from you about adding tests to this, we're going to close the PR. Feel free to re-open with some tests if you get the time in the future!

@chohmann chohmann closed this Jun 3, 2022
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.

2 participants