PHP Класс Garden\Validation

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$errors Properties ///
$mainMessage
$status

Открытые методы

Метод Описание
__construct ( array $errors = [], string $mainMessage = '', integer $status ) Initialize an instance of the {@link Validation} class.
addError ( string $messageCode, string | array $field = '*', integer | array $options = [] ) : Validation Add an error.
errorMessage ( array $error ) : string Gets the error message from an error.
fieldValid ( string $field ) : boolean Check whether or not a particular field is has errors.
getErrorsFlat ( ) : array Gets all of the errors as a flat array.
getMessage ( ) : string Get the message for this exception.
isValid ( ) : boolean Check whether or not the validation is free of errors.
mainMessage ( string | null $value = null ) : Validation | string Gets the main error message for the validation.
status ( integer | null $value = null ) : Validation | integer Get or set the error status code.

Приватные методы

Метод Описание
arraySelect ( array $keys, array $array, mixed $default = null ) : mixed Select the first non-empty value from an array.

Описание методов

__construct() публичный Метод

Initialize an instance of the {@link Validation} class.
public __construct ( array $errors = [], string $mainMessage = '', integer $status )
$errors array An array of errors.
$mainMessage string The main message of the error.
$status integer The http status code of the error or 0 to build the status code from the indivdual errors.

addError() публичный Метод

Add an error.
public addError ( string $messageCode, string | array $field = '*', integer | array $options = [] ) : Validation
$messageCode string The message translation code. If you add a message that starts with "@" then no translation will take place.
$field string | array The name of the field to add or an array of fields if the error applies to more than one field.
$options integer | array An array of additional information to add to the error entry or a numeric error code.
Результат Validation Returns $this for fluent calls.

errorMessage() публичный статический Метод

Errors are stored with either a message or a translation code. This method will look at both to determine the full message.
public static errorMessage ( array $error ) : string
$error array The error array.
Результат string Returns the message from the error.

fieldValid() публичный Метод

Check whether or not a particular field is has errors.
public fieldValid ( string $field ) : boolean
$field string The name of the field to check for validity.
Результат boolean Returns true if the field has no errors, false otherwise.

getErrorsFlat() публичный Метод

The errors are internally stored indexed by field. This method flattens them for final error returns.
public getErrorsFlat ( ) : array
Результат array Returns all of the errors.

getMessage() публичный Метод

Get the message for this exception.
public getMessage ( ) : string
Результат string Returns the exception message.

isValid() публичный Метод

Check whether or not the validation is free of errors.
public isValid ( ) : boolean
Результат boolean Returns true if there are no errors, false otherwise.

mainMessage() публичный Метод

Gets the main error message for the validation.
public mainMessage ( string | null $value = null ) : Validation | string
$value string | null Pass a new main message or null to get the current main message.
Результат Validation | string Returns the main message or $this for fluent sets.

status() публичный Метод

The status code is an http resonse code and should be of the 4xx variety.
public status ( integer | null $value = null ) : Validation | integer
$value integer | null Pass a new status code or null to get the current code.
Результат Validation | integer Returns the current status code or $this for fluent sets.

Описание свойств

$errors защищенное свойство

Properties ///
protected $errors

$mainMessage защищенное свойство

protected $mainMessage

$status защищенное свойство

protected $status