\app\framework\Component\Route\KleinValidator

Validator

Summary

Methods
Properties
Constants
__construct()
addDefault()
addValidator()
__call()
$methods
No constants found
No protected methods found
$str
$err
$default_added
N/A
No private methods found
No private properties found
N/A

Properties

$methods

$methods : 

The available validator methods

Type

$str

$str : 

The string to validate

Type

$err

$err : 

The custom exception message to throw on validation failure

Type

$default_added

$default_added : 

Flag for whether the default validation methods have been added or not

Type

Methods

__construct()

__construct(string  $str, string  $err = null) 

Sets up the validator chain with the string and optional error message

Parameters

string $str

The string to validate

string $err

The optional custom exception message to throw on validation failure

addDefault()

addDefault() : void

Adds default validators on first use

addValidator()

addValidator(string  $method, callable  $callback) : void

Add a custom validator to our list of validation methods

Parameters

string $method

The name of the validator method

callable $callback

The callback to perform on validation

__call()

__call(string  $method, array  $args) : \app\framework\Component\Route\Klein\Validator|boolean

Magic "__call" method

Allows the ability to arbitrarily call a validator with an optional prefix of "is" or "not" by simply calling an instance property like a callback

Parameters

string $method

The callable method to execute

array $args

The argument array to pass to our callback

Throws

\BadMethodCallException

If an attempt was made to call a validator modifier that doesn't exist

\app\framework\Component\Route\Klein\Exceptions\ValidationException

If the validation check returns false

Returns

\app\framework\Component\Route\Klein\Validator|boolean