elm-validate icon indicating copy to clipboard operation
elm-validate copied to clipboard

`ifNotFloat` has different behavior than `ifNotInt`

Open jaredramirez opened this issue 4 years ago • 0 comments

The function ifNotFloat will error if the subject is a float, whereas ifNotInt will error if the subject is not an int. I believe the behavior of ifNotInt is correct. In the definition of isNotFloat, ifTrue, should be ifFalse.

The current definition:

ifNotFloat : (subject -> String) -> error -> Validator error subject
ifNotFloat subjectToString error =
    ifTrue (\subject -> isFloat (subjectToString subject)) error

The correct definition:

ifNotFloat : (subject -> String) -> error -> Validator error subject
ifNotFloat subjectToString error =
    ifFalse (\subject -> isFloat (subjectToString subject)) error

Note: The definition of ifNotFloat and ifNotInt also differ in the second argument as well. ifNotInt takes a function with the invalid int, whereas ifNotFloat takes just the error. Any changes to ifNotFloat should probably also reconcile the definitions to be the same.

jaredramirez avatar Feb 24 '20 22:02 jaredramirez