Esempio n. 1
0
 static function standard_instance($input = null)
 {
     if ($input === null) {
         $input = self::input();
     }
     $conform = new self($input);
     $conform->add_conformer('f', \Grithin\Conform\Filter::init());
     $conform->add_conformer('v', new \Grithin\Conform\Validate());
     return $conform;
 }
Esempio n. 2
0
 function __construct()
 {
     $this->input = $input = ['bob' => 'bob', 'email' => '*****@*****.**', 'price' => '$14,240.02', 'float' => 12.1, 'int' => 2, 'int_string' => ' 2'];
     $this->conform = new \Grithin\Conform($input);
     $this->conform->add_conformer('f', \Grithin\Conform\Filter::init());
     $this->conform->add_conformer('v', new \Grithin\Conform\Validate());
     $e = function () {
         throw new \Exception();
     };
     $this->conform->add_conformer('e', $e);
 }
Esempio n. 3
0
 function international_phone($v)
 {
     $v = Filter::digits($v);
     self::filled($v);
     if (strlen($v) < 11) {
         self::error();
     }
     if (strlen($v) > 14) {
         self::error();
     }
     return $v;
 }
Esempio n. 4
0
		'type' : 'v.int'
		'params' : []
	]
]
*/
Debug::out($conform->output);
/*
[
	'clicks' : 2
]
*/
# input assumed from normal stdin and POST and GET
$rules = ['hits' => 'v.int', 'clicks' => 'v.int v.min|1'];
$_POST = ['hits' => 'v.int', 'clicks' => 'v.int v.min|1'];
$conform = new \Grithin\Conform($input);
$conform->add_conformer('f', \Grithin\Conform\Filter::init());
$conform->add_conformer('v', new \Grithin\Conform\Validate());
$e = function () {
    throw new \Exception();
};
$conform->add_conformer('e', $e);
Debug::out($conform->fields_rules($rules));
/*
[
	'clicks' : 2
]
*/
Debug::out($conform->standardise_errors());
/*
0 : [
		'fields' : [