Snaju Inception Docs

ValidatorRule

A flexible class used to determine if a data value is "valid" passing any, checks specified in the `isValid` method. Returning false, results in an error being recorded and sent to the client making the request.

Table of Contents

$field  : string
The property name on the data array.
$nestedLookup  : bool
Determines whether this method should drill down the array to validate other arrays and objects it finds.
$optional  : bool
Used to determine if the validator can pass if the field is null, empty, or not provided.
$ruleValue  : mixed
The property's value on the data array.
$usesRequestData  : bool
Convenience method to determine if the Rule is using the raw request data or data from another source.
__construct()  : mixed
ValidatorRule constructor.
getErrorMessage()  : string
Returns the error message string to show as feedback if the validator fails.
getRuleValue()  : mixed
Returns the rule's value to use for validation against the data value.
isValid()  : bool
Returns true if the value passes the validator's checks.
stopOnError()  : bool
When this returns true, all other validators are not ran and the Validator returns this error and any other errors encountered before this rule.

Properties

$field

The property name on the data array.

protected string $field

$nestedLookup

Determines whether this method should drill down the array to validate other arrays and objects it finds.

protected bool $nestedLookup = false

$optional

Used to determine if the validator can pass if the field is null, empty, or not provided.

protected bool $optional

$ruleValue

The property's value on the data array.

protected mixed $ruleValue

$usesRequestData

Convenience method to determine if the Rule is using the raw request data or data from another source.

protected bool $usesRequestData

Methods

__construct()

ValidatorRule constructor.

public __construct( $field,  $ruleValue,  $usesRequestData[, false $optional = false ]) : mixed
Parameters
$field :
$ruleValue :
$usesRequestData :
$optional : false = false
Return values
mixed

getErrorMessage()

Returns the error message string to show as feedback if the validator fails.

public abstract getErrorMessage() : string
Return values
string

getRuleValue()

Returns the rule's value to use for validation against the data value.

public getRuleValue() : mixed

For example, if MinRule is used min:6, this method would return 6.

Return values
mixed

isValid()

Returns true if the value passes the validator's checks.

public abstract isValid( $dataArray) : bool
Parameters
$dataArray :
Return values
bool

stopOnError()

When this returns true, all other validators are not ran and the Validator returns this error and any other errors encountered before this rule.

public stopOnError() : bool
Return values
bool

Search results