-
Notifications
You must be signed in to change notification settings - Fork 14
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
Implement multipleOf #29
Conversation
Test failures are introduced in hhvm 4.0. I'll use alternatives that do work. |
HHVM 4.0 does not allow reading from unknown fields using `??` This was acutally a correct check This saves us from the bug where someone does `"multipleOf": "cow"`
$remainer = Math\abs( | ||
$dividend is int && $devisor is int ? $dividend % $devisor : \fmod((float)$dividend, (float)$devisor), | ||
); | ||
\var_dump(dict[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you're still working on this, but we'll want to take this out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The var_dump()
was for debugging purposes.
Will be I'll remove it.
use namespace HH\Lib\Math; | ||
use namespace Slack\Hack\JsonSchema; | ||
|
||
const float COMPARISON_LEEWAY = 10. ** -6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do.
throw new JsonSchema\InvalidFieldException($pointer, vec[$error]); | ||
} | ||
if ($remainer is float) { | ||
if ($remainer < $devisor / 2 && $remainer > COMPARISON_LEEWAY) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to have a comment about this logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is a good plan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you!
To quote John F. Kennedy
Partially addresses #7