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
In the isBefore() method, before it does the comparison, it converts both arguments to a date using the toDate() helper. If the argument passed into toDate() is not a valid date, it returns null. However, this means that when we get to the comparison line (https://github.com/chriso/validator.js/blob/master/validator.js#L483), if the original variable is null, that line evaluates to null.
Is this the intended functionality? Shouldn't all validation functions return a boolean? If so, shouldn't we convert those toDate() variables to booleans so that the line would be something like return !!original && !!comparison && original < comparison;?
If this is actually a bug, just let me know and I can open a PR. If it is not a bug, I can find a way to work around it.
The text was updated successfully, but these errors were encountered:
In the
isBefore()
method, before it does the comparison, it converts both arguments to a date using thetoDate()
helper. If the argument passed intotoDate()
is not a valid date, it returnsnull
. However, this means that when we get to the comparison line (https://github.com/chriso/validator.js/blob/master/validator.js#L483), if theoriginal
variable is null, that line evaluates to null.Is this the intended functionality? Shouldn't all validation functions return a boolean? If so, shouldn't we convert those
toDate()
variables to booleans so that the line would be something likereturn !!original && !!comparison && original < comparison;
?If this is actually a bug, just let me know and I can open a PR. If it is not a bug, I can find a way to work around it.
The text was updated successfully, but these errors were encountered: