PHP 클래스 Garden\Validation

파일 보기 프로젝트 열기: vanilla/vanilla 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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