Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom validation for built-in rules #119

Merged
merged 4 commits into from
Mar 21, 2020
Merged

Custom validation for built-in rules #119

merged 4 commits into from
Mar 21, 2020

Conversation

erfanium
Copy link
Collaborator

Related to #100
Customizing built-in rules, without creating new rule.
For example:

check = v.compile({
   num: {
      type: "number",
      min: 10,
      max: 15,
      integer: true,
      custom (value, schema) {
         if (value % 2 !== 0) return [{ type: "evenNumber", actual: value }];
      }
   }
});

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 384c3b6 on erfanium:master into d1edb33 on icebob:master.

@erfanium
Copy link
Collaborator Author

@icebob
Any opinion? Proposal? Criticism? :-)

@icebob
Copy link
Owner

icebob commented Mar 21, 2020

The idea is good.
But I should check the code & check the performance of PR. If it's ok I will merge it.

@icebob icebob merged commit d9239da into icebob:master Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants