validatorjs icon indicating copy to clipboard operation
validatorjs copied to clipboard

Add custom validation rules to a single Validator instance

Open renarsvilnis opened this issue 8 years ago • 1 comments

Feature request:

Allow to use register and registerAsync on a new Validator instance to register custom rules that are only scoped to the instance.

My proposal is to add rules property to the options object in the constructor (explained in more detailed #97). Where rules would be an object where the keys are the rule names and the their values would be functions.

~~But that would require changes on how custom validation functions are registered. As of now you must pass a errorMessage on calling register function, but for the registerAsync the errorMessage is passed to the pass(false, errorMessage). There is a need normalizing the arguments for both register and registerAsync.~~ Looked at source-code, looks like README.md is not update-to-date.

What are you thoughts about this? I can make a PR if interested.

renarsvilnis avatar Jul 01 '16 10:07 renarsvilnis

I also would like this feature to be implemented.

goshoo avatar Jan 18 '17 10:01 goshoo