Last Updated: February 25, 2016
·
943
· 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();

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside