...
This helper allows users to validate fields against regular expressions eg. in the failsWhenExpression as below
...
Date Validation
This helper function allows users to validate the date field by checking whether the selected date is in the past or future by comparing it with a base date.
Example:
Consider a scenario where a patient wishes to book an appointment with a doctor. The appointment date should be in the future and not in the past. If the patient mistakenly books an appointment for a past date, it leads to an invalid appointment. To prevent this, the date field should be validated to ensure the selected date is not in the past, thereby guiding the patient to choose a valid appointment date.
Code Example
Code Block | ||
---|---|---|
| ||
"validators": [
{
"type": "js_expression",
"failsWhenExpression": "isDateBefore(appointment, '2024-07-13')",
"message": "Appointment cannot be in the past"
}
] |