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

Ability to register a rule per validator instance #465

Open
foxhound87 opened this issue Apr 4, 2023 · 0 comments
Open

Ability to register a rule per validator instance #465

foxhound87 opened this issue Apr 4, 2023 · 0 comments

Comments

@foxhound87
Copy link

Hello,
right now to register a new rule you have to call Validator.register() and the rule is available in a new Validator instance.
But I have an issue when registering multiple rule functions with same key/name, the functions takes in input the arguments of the last registered rule.

Would be nice to have the ability to create specific rules for each validator instance.
Something like this:

const validator = new Validator(); // empty constructor 
validator.register(name, callbackFn, errorMessage);

const validation = validator.validate(data, rules);
validation.passes(); // true
validation.fails(); // false

Related Issue: foxhound87/mobx-react-form#579

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

No branches or pull requests

1 participant