-
Notifications
You must be signed in to change notification settings - Fork 30
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
Validation issue with strictMode and the multipleOf keyword in Ajv when using decimal numbers #50
Comments
Update: Perhaps we could use |
Thanks for the report. I will put together some test cases and see if either of these options fix the issue. Leave it with me 👍 |
Thank you for the detailed description of the problem and the suggested fixes. I settled on a solution that was a combination of both of these ideas. Rather than add Fixed in 55a85b9. Version 2.0.1 published to npm. |
Hi @mikuso Thanks a ton for getting back to me so quickly and fixing the issue. I gave version 2.0.1 a try, and I'm happy to report that the problem with Ajv's precision has been sorted out. Awesome! I just wanted to drop a quick note to express my gratitude for not only resolving the issue but also for creating such an amazing library that makes implementing OCPP-related features a piece of cake. |
Thanks for the kind words. Much appreciated. |
Hi,
I noticed that there is a validation issue with the
strictMode
andmultipleOf
keyword inAjv
when using decimal numbers. When I receive a certain PDU ofGetCompositeSchedule.conf
, I encounter an error message stating "data/chargingSchedule/chargingSchedulePeriod/0/limit must be a multiple of 0.1". This occurs because the value of the limit (9.1) is not considered a multiple of 0.1 due to a precision issue in JavaScript where9.1
/0.1
is equal to90.99999999999999
.I understand that this is an issue with Ajv. However, I was wondering if we could implement a temporary workaround for this problem until Ajv addresses it. One possible solution could be to modify the Ajv configuration by removing the default "multipleOf" keyword and adding a custom implementation that handles decimal numbers using the "number-precision" library.
Here's an example of how we could modify the Ajv configuration:
ajv-validator/ajv#652 (comment)
By implementing this workaround, we can handle decimal numbers more accurately in validation process.
Let me know if you have any further questions or if there's anything else I can assist you with.
The text was updated successfully, but these errors were encountered: