Property | Type | Description | |
---|---|---|---|
$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' |
Method | Description | |
---|---|---|
__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 = '' ) : |
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 |
Method | Description | |
---|---|---|
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 |
protected construcRuleByNameAndOptions ( $name, $options ) : Sirius\Validation\Rule\Callback | ||
$name | ||
$options | ||
return | Sirius\Validation\Rule\Callback |
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 |
return | Sirius\Validation\Rule\AbstractValidator |
protected registerDefaultRules ( ) |
protected array $validatorsMap | ||
return | array |