avram icon indicating copy to clipboard operation
avram copied to clipboard

validate_numeric condition confusion

Open jwoertink opened this issue 3 years ago • 1 comments

Looking at this code:

validate_numeric amount, greater_than: 0

You'd assume that this is validating to ensure amount > 0, but it doesn't. You can actually set amount to 0 and it'll still validate.

https://github.com/luckyframework/avram/blob/60108b570fee5128e0f47f3d12c49d48007c3eb8/src/avram/validations.cr#L270

In this case, it's working more like greater_than_and_equal_to because 0 < 0 is false.

jwoertink avatar Mar 07 '22 18:03 jwoertink

I'm sure it's the same with less_than, but that wasn't tested in our code.

jwoertink avatar Mar 07 '22 18:03 jwoertink