Using validator I try to create a simple and elegant validation flow. All validation requirements should be placed in a single json config file, like this one(for example):
{
name: {
required: true,
validator: isLength,
config: {min:3, max:99}
}
}
I wrote a function that builds a string:
var func = 'Validator.'+funcName+'('+value+','+config+')';
Now I want to execute that string as a function.
I tried it like this(where result is func):
var bla = new Function(Validator, result);
But I get the following warning:
Validator.isLength(jonathan,{min:0, max:10})
validator deprecated you tried to validate a undefined but this library (validator.js) validates strings only. Please update your code as this will be an error soon. native v8natives.js:1259:8
Is there a better way to do what I want, and how can I get it working ?
Thanks