rudie dirkx - 2011-01-11 08:57:11
If you have to 'manually' put the data into the validationset, it's kind of useless isn't it? The validationset and the data should be separate. Something like this:
$v = new Validator;
$v->add('username', new Validate_Unique('Username must be unique!'));
$v->add('password', new Validate_NotEmpty('Please enter a password...'))
$v->add('position', function($v) {
return rand(0, 1) ? 'This is not a valid function!!' : true;
});
etc
or like
$v->add(array(
'username' => new Validate_...,
'password' => new Validate_...,
'position' => function($v) { }
));
and then to validate:
$v->validate($_POST);
or
$v->validate($this->data);
if you use a framework.
PS. I've only seen the example file (by far the most important always), not the actual class.