class Validator

Class Validator

Properties

protected EventDispatcherInterface $eventDispatcher
protected ValidationRuleInterface[] $validationRules
protected array $errors
protected array $constraints

Methods

__construct(EventDispatcherInterface $eventDispatcher)

Validator constructor.

$this
registerValidationRule(ValidationRuleInterface $validationRule)

No description

$this
addConstraint(string $validationRule, array $params = [])

No description

array
getDefaultConstraintParams()

No description

$this
addError(string $message, string|array $field = '')

No description

string
mapField(string|array $field)

No description

dispatchValidationEvent(string $eventName, array $formData, array $extra = [])

No description

validate()

Validates a form

bool
hasErrors()

No description

bool
is(string $validationRule, mixed $field)

No description

Details

at line 37
__construct(EventDispatcherInterface $eventDispatcher)

Validator constructor.

Parameters

EventDispatcherInterface $eventDispatcher

at line 47
$this registerValidationRule(ValidationRuleInterface $validationRule)

Parameters

ValidationRuleInterface $validationRule

Return Value

$this

at line 60
$this addConstraint(string $validationRule, array $params = [])

Parameters

string $validationRule
array $params

Return Value

$this

at line 73
protected array getDefaultConstraintParams()

Return Value

array

at line 89
$this addError(string $message, string|array $field = '')

Parameters

string $message
string|array $field

Return Value

$this

at line 106
protected string mapField(string|array $field)

Parameters

string|array $field

Return Value

string

at line 120
dispatchValidationEvent(string $eventName, array $formData, array $extra = [])

Parameters

string $eventName
array $formData
array $extra

at line 131
validate()

at line 171
protected bool hasErrors()

Return Value

bool

at line 183
bool is(string $validationRule, mixed $field)

Parameters

string $validationRule
mixed $field

Return Value

bool

Exceptions

ValidationRuleNotFoundException