PHP Class Sirius\Validation\Validator

Inheritance: implements Sirius\Validation\ValidatorInterface
Afficher le fichier Open project: siriusphp/validation Class Usage Examples

Protected Properties

Свойство Type Description
$dataWrapper Sirius\Validation\DataWrapper\WrapperInterface The object that will contain the data
$errorMessagePrototype Sirius\Validation\ErrorMessage
$messages array
$ruleFactory RuleFactory
$rules array
$wasValidated boolean

Méthodes publiques

Méthode Description
__construct ( RuleFactory $ruleFactory = null, Sirius\Validation\ErrorMessage $errorMessagePrototype = null )
add ( string $selector, string | callback $name = null, string | array $options = null, string $messageTemplate = null, string $label = null ) : Validator
addMessage ( string $item, string $message = null ) : self
addMultiple ( array $selectorRulesCollection ) : Validator
clearMessages ( string $item = null ) : self Clears the messages of an item
getDataWrapper ( mixed $data = null ) : Sirius\Validation\DataWrapper\WrapperInterface The data wrapper will be used to wrap around the data passed to the validator This way you can validate anything, not just arrays (which is the default)
getErroMessagePrototype ( ) : Sirius\Validation\ErrorMessage Retrieve the error message prototype
getMessages ( string $item = null ) : array
getRuleFactory ( ) : RuleFactory Retrieve the rule factory
getRules ( )
remove ( string $selector, mixed $name = true, mixed $options = null ) : self
setData ( $data )
setErrorMessagePrototype ( Sirius\Validation\ErrorMessage $errorMessagePrototype ) : Sirius\Validation\Rule\AbstractValidator
validate ( mixed $data = null ) : boolean Performs the validation

Méthodes protégées

Méthode Description
ensureSelectorRulesExist ( string $selector, string $label = null )

Method Details

__construct() public méthode

public __construct ( RuleFactory $ruleFactory = null, Sirius\Validation\ErrorMessage $errorMessagePrototype = null )
$ruleFactory RuleFactory
$errorMessagePrototype Sirius\Validation\ErrorMessage

add() public méthode

public add ( string $selector, string | callback $name = null, string | array $options = null, string $messageTemplate = null, string $label = null ) : Validator
$selector string
$name string | callback
$options string | array
$messageTemplate string
$label string
Résultat Validator

addMessage() public méthode

public addMessage ( string $item, string $message = null ) : self
$item string data identifier (eg: 'email', 'addresses[0][state]')
$message string
Résultat self

addMultiple() public méthode

public addMultiple ( array $selectorRulesCollection ) : Validator
$selectorRulesCollection array
Résultat Validator

clearMessages() public méthode

Clears the messages of an item
public clearMessages ( string $item = null ) : self
$item string
Résultat self

ensureSelectorRulesExist() protected méthode

protected ensureSelectorRulesExist ( string $selector, string $label = null )
$selector string
$label string

getDataWrapper() public méthode

The data wrapper will be used to wrap around the data passed to the validator This way you can validate anything, not just arrays (which is the default)
public getDataWrapper ( mixed $data = null ) : Sirius\Validation\DataWrapper\WrapperInterface
$data mixed
Résultat Sirius\Validation\DataWrapper\WrapperInterface

getErroMessagePrototype() public méthode

Retrieve the error message prototype
public getErroMessagePrototype ( ) : Sirius\Validation\ErrorMessage
Résultat Sirius\Validation\ErrorMessage

getMessages() public méthode

public getMessages ( string $item = null ) : array
$item string key of the messages array (eg: 'password', 'addresses[0][line_1]')
Résultat array

getRuleFactory() public méthode

Retrieve the rule factory
public getRuleFactory ( ) : RuleFactory
Résultat RuleFactory

getRules() public méthode

public getRules ( )

remove() public méthode

public remove ( string $selector, mixed $name = true, mixed $options = null ) : self
$selector string data selector
$name mixed rule name or true if all rules should be deleted for that selector
$options mixed rule options, necessary for rules that depend on params for their ID
Résultat self

setData() public méthode

public setData ( $data )

setErrorMessagePrototype() public méthode

public setErrorMessagePrototype ( Sirius\Validation\ErrorMessage $errorMessagePrototype ) : Sirius\Validation\Rule\AbstractValidator
$errorMessagePrototype Sirius\Validation\ErrorMessage
Résultat Sirius\Validation\Rule\AbstractValidator

validate() public méthode

Performs the validation
public validate ( mixed $data = null ) : boolean
$data mixed array to be validated
Résultat boolean

Property Details

$dataWrapper protected_oe property

The object that will contain the data
protected WrapperInterface,Sirius\Validation\DataWrapper $dataWrapper
Résultat Sirius\Validation\DataWrapper\WrapperInterface

$errorMessagePrototype protected_oe property

protected ErrorMessage,Sirius\Validation $errorMessagePrototype
Résultat Sirius\Validation\ErrorMessage

$messages protected_oe property

protected array $messages
Résultat array

$ruleFactory protected_oe property

protected RuleFactory,Sirius\Validation $ruleFactory
Résultat RuleFactory

$rules protected_oe property

protected array $rules
Résultat array

$wasValidated protected_oe property

protected bool $wasValidated
Résultat boolean