validate.MinMax allows for odd usages
validate.MinMax uses Ordered as a constraint, which allows a user to pass in a string:
err := validate.All(
validate.MinMax[string]{
Min: "a", // ascii 97
Max: "b", // ascii 98
Value: "c", // ascii 99 <- over the maximum
},
)
log.Println(err)
// Output: (c) higher than max (b)
This isn't a bug, of course, simply an intended result of the constraint.
However, on my first glance of the library I assumed this would maybe make it possible to validate the length of a string, as this is what the API would seem to suggest (until you properly read into it).
I would suggest either documenting this a little better, or providing options for this common use case.
I might open a PR with a POC for this later, but in the meantime I thought this feedback might help!
Yeah, MinMax is ordering. For length just need separate validator. Good if we can make it to work with strings, slices and maps. Feel free to make PR, or I will add it later!