Last Updated: February 25, 2016
·
696
· gjerokrsteski

Create a factory of rules with Pimf_Util_Validator

 $attributes = array(
  'fname'    => 'conan',
  'age'      => 33,
  'birth'    => '12-12-2040',
  'monitor'  => 'sonyT2000',
);

$rules = array(
  'fname'   => 'alpha|length[>,0]|lengthBetween[1,9]',
  'age'     => 'digit|value[>,18]|value[=,33]',
  'birth'   => 'length[>,0]|date[mm-dd-yyyy]',
  'monitor' => 'alphaNumeric'
);

$validator = Pimf_Util_Validator::factory($attributes, $rules);

 //...
$validator->getErrors();
$validator->getErrorMessages();