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.

Custom validation example is broken

See original GitHub issue

There is no controls and values variables in the code provided in README.

  myValidators = {
    "/passwordCheck": (value, property, form) => {
      if (controls.password !== undefined && controls.password.valid && value !== values.password) {
        return { "passwordCheck": { "expectedValue": "same as 'password'" } }
      }
      return null;
    }
  }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

2reactions
daniele-pecoracommented, May 13, 2019

Hi @JianhuisHuang , I just updated the example at stackblitz. So there is now also an example with a custom validator using custom error messages.

Bildschirmfoto 2019-05-13 um 23 26 58

This is a common structure for an error object to return in your custom validator

    const error = {
      code: 'MUST_NOT_MATCH_NAME',
      path: `#${forenameProperty.path}`,
      message: '"Forename" must be different then "Name"',
      params: [value]
    }
  • code
    you can freely choose this
  • path
    the path of the property this error should be addressed to and marked invalid
  • message
    some validation error text
  • value
    some values to replace in text template
2reactions
EricsG95commented, Oct 4, 2018

Same here, I was following the readme on custom validation but it doesn’t wrok correctly. It looks like the guide is missing some details. Please update, greatly appreciate it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Validator not firing - Stack Overflow
Basically, I have an asp:customvalidator that I am trying to add to a validationgroup with other validators so that all error messages ...
Read more >
Custom validation not working on clientside - MSDN - Microsoft
I've used an example I found to create a custom dataannotationattribute in mvc. It's working on the serverside, but not on the clientside....
Read more >
15.11 Creating and Using a Custom Validator - Java Platform ...
For example, an e-commerce application might use a general-purpose custom validator called FormatValidator.java to validate input data against a format ...
Read more >
Custom Data Validation in Excel : formulas and rules - Ablebits
Learn how to use custom Data Validation in Excel with your own rules and formulas. Formula examples to allow only numbers or text...
Read more >
DevExtreme - JavaScript Validator Custom Rule
Set this field to "custom" to define a rule that will be broken as a result of custom validation performed by the validationCallback...
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