Class Pinoco_Validator
Procedural validation utility.
$validator = new Pinoco_Validator($data); $validator->check('name')->is('not-empty')->is('max-length 255'); $validator->check('age')->is('not-empty')->is('integer') ->is('>= 21', 'Adult only.'); if ($validator->valid) { echo "OK"; } else { foreach ($validator->errors as $field=>$context) { echo $field . ":" . $context->message . "\n"; } }
Builtin tests: pass, fail, empty, not-empty, max-length, min-length, in a,b,c, not-in a,b,c, numeric, integer, alpha, alpha-numeric, == n, != n, > n, >= n, < n, <= n, match /regexp/, not-match /regexp/, email, url
- Pinoco_Vars implements IteratorAggregate, ArrayAccess, Countable, Pinoco_ArrayConvertible
- Pinoco_DynamicVars
- Pinoco_Validator
Copyright: Copyright 2010-2012, Hisateru Tanaka <tanakahisateru@gmail.com>
License: License (http://www.opensource.org/licenses/mit-license.php)
Author: Hisateru Tanaka <tanakahisateru@gmail.com>
Located at Pinoco/Validator.php
public
|
|
public
|
#
defineValidityTest( string $testName, callable $callable, string $message, boolean $complex = false )
Defines custom test. |
public
|
#
defineFilter( string $filterName, callable $callable, boolean $complex = false )
Defines custom filter. |
public
|
|
public
string
|
|
public
array
|
#
fetchExistenceAndValue( string $name )
Check existence and fetch value at the same time. (called by self and validation context) |
public
array
|
#
execValidityTest( string $field, boolean $filtered, mixed $filteredValue, string $testName, string $param )
Executes validation test. (called by validation context) |
public
array
|
#
execValidityTestAll( string $field, boolean $filtered, mixed $filteredValue, string $testName, string $param )
Executes validation test to array with logical AND. (called by validation context) |
public
array
|
#
execValidityTestAny( string $field, boolean $filtered, mixed $filteredValue, string $testName, string $param )
Executes validation test to array with logical OR. (called by validation context) |
public
array
|
#
execFilter( string $field, boolean $filtered, mixed $filteredValue, mixed $filterName, string $param )
Executes filter. (called by validation context) |
public
array
|
#
execFilterMap( string $field, boolean $filtered, mixed $filteredValue, mixed $filterName, string $param )
Executes filter for each elements. (called by validation context) |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
boolean
|
|
public
boolean
|
|
public static
|
#
emptyResult( array $values = array() )
Returns all succeeded checking results to be used in form's initial state. If you fetch a field not given by $values, you will get a passed checking context instead. |
get(),
getIterator(),
has(),
keys(),
set()
|
__call(),
__get(),
__isset(),
__set(),
__toString(),
__unset(),
count(),
fromArray(),
import(),
markAsDirty(),
offsetExists(),
offsetGet(),
offsetSet(),
offsetUnset(),
registerAsDynamic(),
registerAsLazy(),
registerAsMethod(),
remove(),
rget(),
setDefault(),
setLoose(),
toArray(),
toArrayRecurse(),
values(),
wrap()
|
protected
mixed
|
$_tests |
|
|
protected
mixed
|
$_filters |
|
|
protected
mixed
|
$_messages |
|
public read-only
|
$result |
#
All context objects. |
public read-only
|
$errors |
#
Invalid context objects only. |
public read-only
|
$values |
#
Validated values unwrapped. |
public read-only
boolean
|
$valid |
#
Totally valid or not. |
public read-only
boolean
|
$invalid |
#
Totally invalid or not. |