RequiredRule
extends ValidatorRule
in package
Validates that a value has been provided for the specified field and is not empty or null.
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
Return values
mixed —getErrorMessage()
Returns the error message string to show as feedback if the validator fails.
public
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
isValid(mixed $dataArray) : bool
Parameters
- $dataArray : mixed
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