Overview

Packages

  • Pinoco
    • PAL

Classes

  • Pinoco
  • Pinoco_Delegate
  • Pinoco_DynamicVars
  • Pinoco_HttpRequestVars
  • Pinoco_List
  • Pinoco_MIMEType
  • Pinoco_NativeRenderer
  • Pinoco_NothingVars
  • Pinoco_NullRenderer
  • Pinoco_OptionalParam
  • Pinoco_Pagination
  • Pinoco_PDOStatementWrapper
  • Pinoco_PDOWrapper
  • Pinoco_Renderer
  • Pinoco_Router
  • Pinoco_TALRenderer
  • Pinoco_TestEnvironment
  • Pinoco_Validator
  • Pinoco_ValidatorContext
  • Pinoco_Vars

Interfaces

  • Pinoco_ArrayConvertible

Functions

  • __pinoco_autoload_impl
  • Overview
  • Package
  • Class
  • Tree

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
Extended by Pinoco_DynamicVars
Extended by Pinoco_Validator
Package: Pinoco
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
Methods summary
public
# __construct( string $target, array $messages = array() )

Constructor

Constructor

Parameters

$target
string
$target
$messages
array
$messages

Overrides

Pinoco_Vars::__construct()
public
# defineValidityTest( string $testName, callable $callable, string $message, boolean $complex = false )

Defines custom test.

Defines custom test.

Parameters

$testName
string
$testName
$callable
callable
$callable
$message
string
$message
$complex
boolean
$complex
public
# defineFilter( string $filterName, callable $callable, boolean $complex = false )

Defines custom filter.

Defines custom filter.

Parameters

$filterName
string
$filterName
$callable
callable
$callable
$complex
boolean
$complex
public
# overrideErrorMessages( array $messages )

Overrides error messages.

Overrides error messages.

Parameters

$messages
array
$messages
public string
# getMessageFor( string $testName )

Resolve error message by test name.

Resolve error message by test name.

Parameters

$testName
string
$testName

Returns

string
public array
# fetchExistenceAndValue( string $name )

Check existence and fetch value at the same time. (called by self and validation context)

Check existence and fetch value at the same time. (called by self and validation context)

Parameters

$name
string
$name

Returns

array
public array
# execValidityTest( string $field, boolean $filtered, mixed $filteredValue, string $testName, string $param )

Executes validation test. (called by validation context)

Executes validation test. (called by validation context)

Parameters

$field
string
$field
$filtered
boolean
$filtered
$filteredValue
mixed
$filteredValue
$testName
string
$testName
$param
string
$param

Returns

array
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)

Executes validation test to array with logical AND. (called by validation context)

Parameters

$field
string
$field
$filtered
boolean
$filtered
$filteredValue
mixed
$filteredValue
$testName
string
$testName
$param
string
$param

Returns

array
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)

Executes validation test to array with logical OR. (called by validation context)

Parameters

$field
string
$field
$filtered
boolean
$filtered
$filteredValue
mixed
$filteredValue
$testName
string
$testName
$param
string
$param

Returns

array
public array
# execFilter( string $field, boolean $filtered, mixed $filteredValue, mixed $filterName, string $param )

Executes filter. (called by validation context)

Executes filter. (called by validation context)

Parameters

$field
string
$field
$filtered
boolean
$filtered
$filteredValue
mixed
$filteredValue
$filterName
mixed
$filterName
$param
string
$param

Returns

array
public array
# execFilterMap( string $field, boolean $filtered, mixed $filteredValue, mixed $filterName, string $param )

Executes filter for each elements. (called by validation context)

Executes filter for each elements. (called by validation context)

Parameters

$field
string
$field
$filtered
boolean
$filtered
$filteredValue
mixed
$filteredValue
$filterName
mixed
$filterName
$param
string
$param

Returns

array
public Pinoco_ValidatorContext
# contextFor( string $name, string|boolean $label = false )

Returns independent validation context.

Returns independent validation context.

Parameters

$name
string
$name
$label
string|boolean
$label

Returns

Pinoco_ValidatorContext
public Pinoco_ValidatorContext
# check( string $name, string|boolean $label = false )

Starts named property check.

Starts named property check.

Parameters

$name
string
$name
$label
string|boolean
$label

Returns

Pinoco_ValidatorContext
public Pinoco_ValidatorContext
# recheck( string $name, string|boolean $label = false )

Clears previous result and restarts named property check.

Clears previous result and restarts named property check.

Parameters

$name
string
$name
$label
string|boolean
$label

Returns

Pinoco_ValidatorContext
public
# uncheck( string $name )

Clears previous result.

Clears previous result.

Parameters

$name
string
$name
public Pinoco_Vars
# get_result( )

Exports test all results.

Exports test all results.

Returns

Pinoco_Vars
public Pinoco_Vars
# get_errors( )

Exports test results only failed.

Exports test results only failed.

Returns

Pinoco_Vars
public Pinoco_Vars
# get_values( )

Exports test results only failed.

Exports test results only failed.

Returns

Pinoco_Vars
public boolean
# get_valid( )

Returns which all tests succeeded or not.

Returns which all tests succeeded or not.

Returns

boolean
public boolean
# get_invalid( )

Returns which validator has one or more failed tests.

Returns which validator has one or more failed tests.

Returns

boolean
public static Pinoco_Vars
# 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.

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.

Parameters

$values
array
$values

Returns

Pinoco_Vars
Methods inherited from Pinoco_DynamicVars
get(), getIterator(), has(), keys(), set()
Methods inherited from Pinoco_Vars
__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()
Properties summary
protected mixed $_tests
#
protected mixed $_filters
#
protected mixed $_messages
#
Magic properties summary
public read-only Pinoco_Vars $result
#

All context objects.

All context objects.

public read-only Pinoco_Vars $errors
#

Invalid context objects only.

Invalid context objects only.

public read-only Pinoco_Vars $values
#

Validated values unwrapped.

Validated values unwrapped.

public read-only boolean $valid
#

Totally valid or not.

Totally valid or not.

public read-only boolean $invalid
#

Totally invalid or not.

Totally invalid or not.

Pinoco 0.8.0 Documentation API documentation generated by ApiGen 2.8.0