avram
avram copied to clipboard
validate_numeric condition confusion
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.
I'm sure it's the same with less_than, but that wasn't tested in our code.