LabelValidator
class LabelValidator extends AbstractValidator (View source)
A validator for labels.
Labels usually allow all kinds of letters, numbers, punctuation marks and the space character. What you don't want in labels though are tabs, new line characters or HTML tags. This validator is for such uses.
Constants
PATTERN_VALIDCHARACTERS |
|
Properties
protected bool | $acceptsEmptyValues | Specifies whether this validator accepts empty values. |
from AbstractValidator |
protected array | $supportedOptions | This contains the supported options, each being an array of: |
from AbstractValidator |
protected array | $options | from AbstractValidator | |
protected Result[] | $resultStack | from AbstractValidator |
Methods
Constructs the validator and sets validation options
Push a new Result onto the Result stack and return it in order to fix cyclic calls to a single validator.
Pop and return the current Result from the stack and make $this->result point to the last Result again.
Get the current Result for this validation invocation. Use this inside your isValid() implementation to e.g. merge results together into the current one.
Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.
The given value is valid if it matches the regular expression specified in PATTERN_VALIDCHARACTERS.
Creates a new validation error object and adds it to $this->errors
Details
__construct(array $options = [])
Constructs the validator and sets validation options
protected Result
pushResult()
Push a new Result onto the Result stack and return it in order to fix cyclic calls to a single validator.
protected Result
popResult()
Pop and return the current Result from the stack and make $this->result point to the last Result again.
protected Result|null
getResult()
Get the current Result for this validation invocation. Use this inside your isValid() implementation to e.g. merge results together into the current one.
Result
validate(mixed $value)
Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.
protected void
isValid(mixed $value)
The given value is valid if it matches the regular expression specified in PATTERN_VALIDCHARACTERS.
protected void
addError(string $message, int $code, array $arguments = [])
Creates a new validation error object and adds it to $this->errors
array
getOptions()
Returns the options of this validator
final protected bool
isEmpty(mixed $value)
No description