Validator

package Klein

 Methods

Magic "__call" method

__call(callable $method, array $args) : \Klein\Validator

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

access public

Parameters

$method

callable

The callable method to execute

$args

array

The argument array to pass to our callback

Exceptions

\BadMethodCallException If an attempt was made to call a validator modifier that doesn't exist
\Klein\Exceptions\ValidationException If the validation check returns false

Returns

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

__construct(string $str, string $err) 
access public

Parameters

$str

string

The string to validate

$err

string

The optional custom exception message to throw on validation failure

Adds default validators on first use

addDefault() : void
Static
static
access public

Add a custom validator to our list of validation methods

addValidator(string $method, callable $callback) : void
Static
static
access public

Parameters

$method

string

The name of the validator method

$callback

callable

The callback to perform on validation

 Properties

 

$methods : array
static
access protected
 

$defaultAdded : boolean
static
access protected
 

$err : string
access protected
 

$str : string
access protected