-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
We need to implement conditional validation to allow rules to be applied only when certain conditions are met. This will enable more complex validation scenarios where some fields are only required or validated based on the values of other fields.
Problem to Solve:
Currently, all validation rules are applied unconditionally, which doesn't work for forms with conditional fields or business logic that depends on specific field values.
Acceptance Criteria:
- Implement
cond:field=valuesyntax to conditionally apply rules - Support for multiple conditions with AND/OR logic
- Support for comparison operators (=, !=, >,
<, >=, <=) - Support for nested field references in conditions
- Add comprehensive tests for conditional validation
- Update documentation with examples
Implementation Suggestions:
- Add a condition parser in the rule executor
- Implement a condition evaluator that checks if conditions are met before applying rules
- Support both simple equality and more complex comparisons
Example Usage:
const rules = [
"shippingAddress-string-cond:needsShipping=true",
"cardNumber-string-16-cond:paymentMethod=credit",
"cvv-number-3-cond:paymentMethod=credit",
"accountNumber-string-cond:paymentMethod=bank"
];Labels: enhancement, conditional-validation, feature
Metadata
Metadata
Assignees
Labels
No labels