pimbrouwers/Validus

Numerical greaterThanOrEqual and lessThanOrEqual do not check for equality

Closed this issue · 1 comments

Basically, it is just this:

    /// Value is greater than provided min with the default error
    /// message
    member _.greaterThan (min : 'a) (field : string) (input : 'a) =
        let msg field = ValidationMessages.greaterThan field min
        x.greaterThan min msg field input

    /// Value is greater than or equal to provided min with the default
    /// error message
    member _.greaterThanOrEqualTo (min : 'a) (field : string) (input : 'a) =
        let msg field = ValidationMessages.greaterThanOrEqualTo field min
        x.greaterThan min msg field input

    /// Value is less than provided max with the default error message
    member _.lessThan (max : 'a) (field : string) (input : 'a) =
        let msg field = ValidationMessages.lessThan field max
        x.lessThan max msg field input

    /// Value is less than or equal to provided max with the default
    /// error message
    member _.lessThanOrEqualTo (max : 'a) (field : string) (input : 'a) =
        let msg field = ValidationMessages.lessThanOrEqualTo field max
        x.lessThan max msg field input

Which needs to be this:

    /// Value is greater than provided min with the default error
    /// message
    member _.greaterThan (min : 'a) (field : string) (input : 'a) =
        let msg field = ValidationMessages.greaterThan field min
        x.greaterThan min msg field input

    /// Value is greater than or equal to provided min with the default
    /// error message
    member _.greaterThanOrEqualTo (min : 'a) (field : string) (input : 'a) =
        let msg field = ValidationMessages.greaterThanOrEqualTo field min
        x.greaterThanOrEqualTo min msg field input

    /// Value is less than provided max with the default error message
    member _.lessThan (max : 'a) (field : string) (input : 'a) =
        let msg field = ValidationMessages.lessThan field max
        x.lessThan max msg field input

    /// Value is less than or equal to provided max with the default
    /// error message
    member _.lessThanOrEqualTo (max : 'a) (field : string) (input : 'a) =
        let msg field = ValidationMessages.lessThanOrEqualTo field max
        x.lessThanOrEqualTo max msg field input

These functions already exist, but just have never been called:

let inline greaterThanOrEqualTo<'a when 'a : comparison> (min : 'a) : ValidationRule<'a> =

Thanks for fixing this @pimbrouwers!!! ❤️