SeViR schrieb:

I would need some methods ("rules" in YAV) in Validation plugin:

//  generic regexp method

$.validator.addMethod("regexp", function(value, element, regular_expression) { return (typeof(regular_expression) == "string")? value.match(new RegExp(regular_expression)) : value.match(regular_expression);
   }, 'Please check if you write it correctly');
Somewhere in the documentation you should find a comment stating that the temptation to add a regex method is great, but should be resisted. I still think that its better to add custom methods that implement those regular expression instead of one generic regex method. By choosing a good name for the method its very clear what is validated, which is not easily figured by looking at a complex regular expression. And heavily increases the chance to reuse regular expressions.
Also I'd like "implies", "and" and "or" methods, but as I see the validator plugin how because you check by element not by rules so. I have some idea for "implies" but not
in "and" and "or" method:

[...]
I haven't understood yet how implies works, but your code seems like a good approach to tackle that feature. Thanks.

--
Jörn Zaefferer

http://bassistance.de

Reply via email to