I'm rewriting my form handler ... part of the update is the inclusion of a nicer way of adding validation to form objects. It's something that's been done a million times before, but I fancied doing my own (mainly so I can make it interact with Twig nicely, but anyway).
So far my validation rules consist of;
Required - Field must be completed
Minimum length - Field must be at least a certain number of characters
Maximum length - Field must be no more than a certain number of characters
Alpha - Field must be letters only.
Alphanumeric - Field must be letters or numbers only.
Numeric - Field must be numbers only.
Equals - Field must be the same as something (another field, a session variable, etc).
Enum - Field must be the same as something in a list of options.
Email - Field must be a valid email address.
URL - Field must be a valid URL.
Regexp - Field must match a regular expression.
Have I missed anything obvious? The regexp option means users will be able to define their own rules easily enough, but if there's something that's used frequently then I'd rather include it now.
Common validation rules
Moderator: General Moderators
Re: Common validation rules
What about :
1.date: different date format
2.range: value between let say x n y
1.date: different date format
2.range: value between let say x n y