Allow custom messages for DVR on a per-field basis
See original GitHub issuehttps://github.com/skaterdav85/validatorjs#custom-error-messages
From their readme:
“”"
You can even provide error messages on a per attribute basis! Just set the message’s key to ‘validator.attribute’
let input = { name: '', email: '' };
let rules = { name : 'required', email : 'required' };
let validation = new Validator(input, rules, {
"required.email": "Without an :attribute we can't reach you!"
});
validation.errors.first('name'); // returns 'The name field is required.'
validation.errors.first('email'); // returns 'Without an email we can\'t reach you!'
“”"
Related code in DVR.js file:
validateFieldSync(field, form, data) {
const $rules = this.rules(field.rules, 'sync');
// exit if no rules found
if (_.isEmpty($rules[0])) return;
// get field rules
const rules = { [field.path]: $rules };
// create the validator instance
const Validator = this.validator;
const validation = new Validator(data, rules);
// set label into errors messages instead key
validation.setAttributeNames({ [field.path]: field.label });
// check validation
if (validation.passes()) return;
// the validation is failed, set the field error
field.invalidate(_.first(validation.errors.get(field.path)));
}
The particular section is new Validator(data, rules)
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
DVR Custom Error Message Per Attribute #368 - GitHub
Same question. How can i set custom error message to field without creating custom validation method? All reactions.
Read more >Upload of custom messages material procedure manual
IMPORTANT NOTE: The custom messages need to be set and uploaded to the my- own-voice website before you start the voice banking process....
Read more >Radar, Message & CMS Boards - Royal Innovative Solutions
Our Mobile DVR and Radar Board keeps your workers safe and protects you from ... changeable message sign (CMS) allows you to customize...
Read more >Configuring Numbers: Voicemail, Music, and Messages
Setting up the Music and Messages on each of your numbers is an essential step in creating a cohesive and custom experience for...
Read more >X1 DVR Services Overview - Xfinity Support
It lets you record any TV program and watch when it's convenient for you. DVR also allows you to rewind and fast-forward live...
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
@Dakkers do you have any updates or how’d you solve this issue?
@andrefox333 you can use any validators at a time, they will be executed in the order you defined them in the
plugins
object.