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.

Feature: Multiple validation rules for the same name/type

See original GitHub issue

Branch: 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:closed
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Vidleccommented, Jan 3, 2018

And I agree messages and rules should be in different files.

0reactions
kettanaitocommented, Jan 31, 2018

Changes implemented and are available since version 0.18.0. Published.

Closing.

Read more comments on GitHub >

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

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