Form validation (class ?)

Small, short code snippets that other people may find useful. Do you have a good regex that you would like to share? Share it! Even better, the code can be commented on, and improved.

Moderator: General Moderators

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

[quote="d11wtq"]The way I've done things lately is like this:

Code: Select all

$request = new Request($_POST);
$request->setValidator(new DefaultValidator(
    array(
        'username' => 'string',
        'email' => array('string', PCRE::email)
    )
));
I reverse that and do:

Code: Select all

$request = new Request();
$validator = new Validator();
$validator->isValid($request);
(#10850)
Post Reply