Closed darkdreamingdan closed 1 year ago
Coercing to string doesn't validate anything at all, because any Python object can be converted to string. I think, it's just useless. As for your example, it's dirty and counter-intuitive. Why just don't use Int(min=999)
instead, if you need to check number?
Hey, perhaps I gave a bad example. Coercing to string by itself doesn't validate anything at all, however it's useful particularly for pattern checks and when the type was originally inferred incorrectly (because of a bug in source data). For example
We can always do this seperately, but sometimes it's useful to use the Str validation arguments on types that aren't initially strings (particularly float
and integer
)
That makes sense.
Hi, fantastic work on this library! I was just wondering why the Str validator doesn't have a
coerce
option. This is useful if you want to, for example, check the length of a number is less than 3 digits:I was just trying to understand if there was any specific reason not to have a coerce for Strings, even if it isn't immediately obviously needed.