PHP 클래스 Sirius\Validation\RuleFactory

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

보호된 프로퍼티들

프로퍼티 타입 설명
$errorMessages array
$labeledErrorMessages array
$validatorsMap array Validator map allows for flexibility when creating a validation rule You can use 'required' instead of 'required' for the name of the rule or 'minLength'/'minlength' instead of 'MinLength'

공개 메소드들

메소드 설명
__construct ( ) Constructor
createRule ( string | callable $name, string | array $options = null, string $messageTemplate = null, string $label = null ) : Sirius\Validation\Rule\AbstractValidator Factory method to construct a validator based on options that are used most of the times
register ( string $name, string $class, $errorMessage = '', $labeledErrorMessage = '' ) : RuleFactory Register a class to be used when creating validation rules
setMessages ( string $rule, string | null $messageWithoutLabel = null, string | null $messageWithLabel = null ) Set default error message for a rule

보호된 메소드들

메소드 설명
construcRuleByNameAndOptions ( $name, $options ) : Sirius\Validation\Rule\Callback
getSuggestedMessageTemplate ( string $name, boolean $withLabel ) : string | null Get the error message saved in the registry for a rule, where the message is with or without a the label
registerDefaultRules ( ) Set up the default rules that come with the library

메소드 상세

__construct() 공개 메소드

Constructor
public __construct ( )

construcRuleByNameAndOptions() 보호된 메소드

protected construcRuleByNameAndOptions ( $name, $options ) : Sirius\Validation\Rule\Callback
$name
$options
리턴 Sirius\Validation\Rule\Callback

createRule() 공개 메소드

Factory method to construct a validator based on options that are used most of the times
public createRule ( string | callable $name, string | array $options = null, string $messageTemplate = null, string $label = null ) : Sirius\Validation\Rule\AbstractValidator
$name string | callable name of a validator class or a callable object/function
$options string | array validator options (an array, JSON string or QUERY string)
$messageTemplate string error message template
$label string label of the form input field or model attribute
리턴 Sirius\Validation\Rule\AbstractValidator

getSuggestedMessageTemplate() 보호된 메소드

Get the error message saved in the registry for a rule, where the message is with or without a the label
protected getSuggestedMessageTemplate ( string $name, boolean $withLabel ) : string | null
$name string name of the rule
$withLabel boolean
리턴 string | null

register() 공개 메소드

Register a class to be used when creating validation rules
public register ( string $name, string $class, $errorMessage = '', $labeledErrorMessage = '' ) : RuleFactory
$name string
$class string
리턴 RuleFactory

registerDefaultRules() 보호된 메소드

Set up the default rules that come with the library
protected registerDefaultRules ( )

setMessages() 공개 메소드

Set default error message for a rule
public setMessages ( string $rule, string | null $messageWithoutLabel = null, string | null $messageWithLabel = null )
$rule string
$messageWithoutLabel string | null
$messageWithLabel string | null

프로퍼티 상세

$errorMessages 보호되어 있는 프로퍼티

protected array $errorMessages
리턴 array

$labeledErrorMessages 보호되어 있는 프로퍼티

protected array $labeledErrorMessages
리턴 array

$validatorsMap 보호되어 있는 프로퍼티

Validator map allows for flexibility when creating a validation rule You can use 'required' instead of 'required' for the name of the rule or 'minLength'/'minlength' instead of 'MinLength'
protected array $validatorsMap
리턴 array