PHP Class Jyxo\Input\Fluent

Allows chaining multiple validators and checking multiple values in one validation cycle.
Author: Jakub Tománek
Datei anzeigen Open project: jyxo/php

Public Methods

Method Description
__construct ( ) Constructor.
__get ( string $offset ) : mixed Magic getter for easier retrieving of values.
all ( ) : self Validates all variables.
check ( mixed $var, string $name ) : self Starts a new value checking.
close ( ) : self Closes a chain.
condition ( string $name, mixed $param = null ) : self Adds a conditional chain.
defaultValue ( mixed $value ) : self Sets a default value in case the validation fails.
file ( string $index ) : self Checks file upload.
filter ( string $name, mixed $param = null ) : self Adds a filter to the chain.s
getErrors ( ) : array Returns errors.
getValue ( string $name ) : mixed Returns a value by name.
getValues ( ) : array Returns all values.
isValid ( boolean $assocErrors = false ) : boolean Performs validation and filtering of all variables.
post ( string $name, mixed $default = null ) : self Checks a POST variable.
query ( string $name, mixed $default = null ) : self Checks a GET variable.
request ( string $name, mixed $default = null ) : self Checks a POST/GET variable
validate ( string $name, string $errorMessage = null, mixed $param = null ) : self Adds a validator to the chain.
validateAll ( ) Calls isValid(), but throws an exception on error.
walk ( boolean $addFilter = true ) : self Adds a subchain to the current chain that treats the value a an array.

Private Methods

Method Description
addToCheck ( array $global, string $name, mixed $default = null ) Adds a variable to the chain.
checkChain ( Chain $chain, mixed &$value, mixed $default, string $name = null ) : boolean Checks a chain.

Method Details

__construct() public method

Constructor.
public __construct ( )

__get() public method

Magic getter for easier retrieving of values.
public __get ( string $offset ) : mixed
$offset string Value name
return mixed

all() public method

Validates all variables.
public all ( ) : self
return self

check() public method

Starts a new value checking.
public check ( mixed $var, string $name ) : self
$var mixed Value to check.
$name string Variable name
return self

close() public method

Closes a chain.
public close ( ) : self
return self

condition() public method

If there are conditions in the current chain, adds the condition as a subchain.
public condition ( string $name, mixed $param = null ) : self
$name string Validator name
$param mixed Additional validator parameter
return self

defaultValue() public method

Sets a default value in case the validation fails.
public defaultValue ( mixed $value ) : self
$value mixed Default value
return self

file() public method

Requires \Jyxo\Input\Upload.
See also: Jyxo\Input\Upload
public file ( string $index ) : self
$index string File index
return self

filter() public method

Adds a filter to the chain.s
public filter ( string $name, mixed $param = null ) : self
$name string Filter name
$param mixed Additional filter parameter
return self

getErrors() public method

Returns errors.
public getErrors ( ) : array
return array

getValue() public method

Returns a value by name.
public getValue ( string $name ) : mixed
$name string Variable name
return mixed

getValues() public method

Returns all values.
public getValues ( ) : array
return array

isValid() public method

Performs validation and filtering of all variables.
public isValid ( boolean $assocErrors = false ) : boolean
$assocErrors boolean Return error messages in an associative array
return boolean

post() public method

Checks a POST variable.
public post ( string $name, mixed $default = null ) : self
$name string Variable name
$default mixed Default value
return self

query() public method

Checks a GET variable.
public query ( string $name, mixed $default = null ) : self
$name string Variable name
$default mixed Default value
return self

request() public method

Checks a POST/GET variable
public request ( string $name, mixed $default = null ) : self
$name string Variable name
$default mixed Default value
return self

validate() public method

Adds a validator to the chain.
public validate ( string $name, string $errorMessage = null, mixed $param = null ) : self
$name string Validator name
$errorMessage string Validator error message
$param mixed Additional validator parameter
return self

validateAll() public method

The exception contains only the first validation error message.
public validateAll ( )

walk() public method

Automatically adds the isArray validator.
public walk ( boolean $addFilter = true ) : self
$addFilter boolean Add the Trim filter (removes empty elements)
return self