Feature: Multiple validation rules for the same name/type
See original GitHub issueBranch: feature/validation-multiple-rules
What
Need to have a support for multiple validation rules for the dedicated name or type.
Why
This would grant a flexible validation procedure coupled with the respective validation messages.
How
Let the validation groups have the named validation rules. Those names will be then used in the validation messages to bind them to the respective message.
Validation rules:
{
type: {
password: {
minLength: ({ value }) => (value.length > 7),
capitalLetter: ({ value }) => ...
}
},
name: {
confirmPassword: {
matches: ({ value, fields }) => (value === fields.password.value)
}
}
}
Validation messages:
{
type: {
password: {
missing: 'Please provide the password.',
invalid: 'General message for unexpected field; fallback for the named rules without the corresponding named message.',
custom/specific/byRule: {
minLength: 'Password must be at least 8 characters long.',
capitalLetter: 'Include at least one capital letter.'
}
}
},
name: {
confirmPassword: {
matches: 'The passwords do not match.'
}
}
}
This should validate the <Field.Input type="password" name="confirmPassword" />
relatively to the password “type” and its messages, and to the “confirmPassword” name and its messages.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Restrict data input by using validation rules - Microsoft Support
You can create two basic types of validation rules: Field validation rules Use a field validation rule to check the value that you...
Read more >jquery validate doesn't work with multiple forms - Stack Overflow
You are attaching .validate() to the element with id="form" $('#form').validate({... However, you have two form elements with this same id .
Read more >Advanced usage - Vuelidate
A simple, but powerful, lightweight model-based validation for Vue.js 3 and 2.
Read more >Validate edits in the utility network with attribute rules
Create a calculation attribute rule that detects a change in the service ... The feature class already has several subtypes and related domains...
Read more >Advanced Usage - React Hook Form
React Hook Form has support for native form validation, which lets you validate inputs with your own rules. Since most of us have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
And I agree messages and rules should be in different files.
Changes implemented and are available since version
0.18.0
. Published.Closing.