Hi,
I looked at phpclasses but saw nothing as simple as I wanted. There's a
Perl module which does just what I want and perhaps I'll have to port
it.
The class accepts an assoc array of name=>value, and the key to another
assoc array which describes the constraints for the assoc array I'm
passing in. Here is an example of the assoc array (it's Perl) which
contains all my "forms" and then the class returns 3 assoc arrays
(valid, invalid,missing using the key names, and this makes it very
easy to use in your templates e.g. if missing_name, or invalid_zipcode
etc.).
my %forms = (
confirm_email => {
required =>
[ qw(emailaddress emailaddress_verified
searchengine_accounts) ],
constraints =>
{
emailaddress_verified => "email",
emailaddress => "email",
},
filters => [ "trim" ],
},
verify_contact_info => {
required =>
[ qw(country lastname firstname phone state zipcode city
company street) ],
optional =>
[ qw(fax) ],
constraints =>
{
#phone => "american_phone",
#zipcode => '/^\s*\d{5}(?:[-]\d{4})?\s*$/',
state => '/\w{2,}/',
#fax => "american_phone",
},
filters => [ "trim" ],
field_filters => { phone => ["phone"] },
},
The Perl module that does this is:
HTML::FormValidator
So far I'm find PHP stuff that does everything under the sun.
Anyone know of something like this?
Peter
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php