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
before/after/onOrBefore/onOrAfter accept function (#281)
The Date validator's before/after/onOrBefore/onOrAfter options now
accept a function that returns a date, which is re-evaluated everytime
the validator runs. This allows the date validation logic to
change in between validations, which is useful for situations where
date validation logic is based on date values that may change in between
validations.
Copy file name to clipboardExpand all lines: README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -197,14 +197,15 @@ Validates the length of a `String` or an `Array`.
197
197
198
198
#### `date`
199
199
200
-
This API accepts valid Date objects or a Date in milliseconds since Jan 1 1970. Strings are currently not supported. It is recommended you use use native JavaScript or you library of choice to generate a date from your data.
200
+
This API accepts valid Date objects or a Date in milliseconds since Jan 1 1970, or a functiom that returns a Date. Strings are currently not supported. It is recommended you use use native JavaScript or you library of choice to generate a date from your data.
201
201
202
202
```js
203
203
{
204
204
propertyName:validateDate({ before:newDate('3000-01-01') }), // must be before 1st Jan. 3000
205
205
propertyName:validateDate({ onOrBefore:Date.parse(newDate('3000-01-01')) }), // must be not after 1st Jan. 3000
206
206
propertyName:validateDate({ after:newDate('3000-01-01') }), // must be after 1st Jan. 3000
207
207
propertyName:validateDate({ onOrAfter:newDate('3000-01-01') }), // must be not before 1st Jan. 3000
208
+
propertyName:validateDate({ onOrAfter: () =>newDate() }), // must not be in the past
0 commit comments