How to validate a string and/or a regular expression

Permalink
C5 allow a basic validation for required form field, integer, mail.
But it seems that no methods are available for validating alfabethical strings or moreover regular expression.
Does anybody know how to do it without patchwork of validation library
thanks

iddue
 
ScottC replied on at Permalink Reply
ScottC
you would either want to create a blank package(that still installs). You would then either want to register an __autoload (defaulting back to the existing autoload that is used for helpers etc by registering a new one), or more easily simply just in the package's on_start method providing your Class and/or functions you want to have available to your concrete5 site. Loader::library('awesome_validation','kibbles_n_bits_package');

Then either statically calling it or creating a new method, this awesome validation class can also inherit from and extend the existing validation class via loading it on line 1 right after the opening tag and adding your new methods for whatever validation you want.

You can also use jquery Validation if you are doing stuff in the dashboard, all of the interface helper submit buttons require javascript so you can assume that if you do your forms correctly your javascript validation will fire before the form actually submits, though the controller validation is more predictable.

hope...that helps?