validatorjs icon indicating copy to clipboard operation
validatorjs copied to clipboard

Add public method to get parsed rules

Open garygreen opened this issue 7 years ago • 1 comments

I would find this particularly useful in dominar.js as I need to determine what data to pass to validator js from the form (in the case of the confirmed and same rule) -- I manually have to parse the rules in pretty much the same way validatorjs does.

It would be nice to get the parsed rules (where all the values have been exploded into a normalized format etc).

This could relate to #89 and improve performance if we allow passing rules to validator that have already been parsed. That way when you re-create the validator, it won't have to re parse the rules as it would detect the rules have already been parsed (might not be a huge speed increase, but still worthwhile).

var parsedRules = Validator.parseRules({ name: 'required' });
var validator = new Validator({ name: 'gary' }, parsedRules);

garygreen avatar Jul 26 '16 10:07 garygreen

So this would make the data structure that gets created in _parsedRules() public?

iamdtang avatar Jul 26 '16 16:07 iamdtang