You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This module currently returns the given value, as is, or null if it doesn't match the given type (or if the type is 'object' and the given value is actually null.)
For .date(), specifically, this means that the caller will still need to check whether it's a number, or a Number, or a Date. Would it make sense to have value-or-function always coerce to one type? E.g. always return Date objects from calls to date with valid argument?
Unlike .date(), the other functions currently are quite strict about their validation, for instance .number() will reject values like new Number(42) or '42'. Would it make sense to make this a bit more forgiving, and like the suggestion above to then coerce to the one type (number in this case)?
It would require a bit of refactoring, but I think it might be helpful (and also make the function name normalize live up to its name). If anyone agrees, I would gladly attempt the change and submit a PR.
The text was updated successfully, but these errors were encountered:
This module currently returns the given value, as is, or
null
if it doesn't match the given type (or if the type is'object'
and the given value is actuallynull
.)For
.date()
, specifically, this means that the caller will still need to check whether it's a number, or a Number, or a Date. Would it make sense to have value-or-function always coerce to one type? E.g. always returnDate
objects from calls todate
with valid argument?Unlike
.date()
, the other functions currently are quite strict about their validation, for instance.number()
will reject values likenew Number(42)
or'42'
. Would it make sense to make this a bit more forgiving, and like the suggestion above to then coerce to the one type (number
in this case)?It would require a bit of refactoring, but I think it might be helpful (and also make the function name
normalize
live up to its name). If anyone agrees, I would gladly attempt the change and submit a PR.The text was updated successfully, but these errors were encountered: