question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow custom messages for DVR on a per-field basis

See original GitHub issue

https://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:open
  • Created 5 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
andrefox333commented, May 21, 2019

@Dakkers do you have any updates or how’d you solve this issue?

0reactions
foxhound87commented, Jun 20, 2019

@andrefox333 you can use any validators at a time, they will be executed in the order you defined them in the plugins object.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found