Validates the input with the Symfony Validator component and outputs it unchanged when it is valid.
- Service:
CleverAge\ProcessBundle\Task\Validation\ValidatorTask
mixed: any value to validate (object, array, scalar).
mixed: the input, unchanged, when there is no violation.
When violations are found, each one is logged (if log_errors is enabled) with the property, violation_code and
invalid_value in the log context, then:
- if
error_output_violationsistrue: theConstraintViolationListInterfaceis sent to the error output and the task is skipped (nothing is sent to the outputs) - otherwise: an
\UnexpectedValueExceptionis thrown (N constraint violations detected on validation), handled according to the taskerror_strategy
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
log_errors |
string|bool |
critical |
PSR log level (Psr\Log\LogLevel values) used to log each violation. true means critical, false disables logging |
|
groups |
array|null |
null |
Validation groups, passed to ValidatorInterface::validate() |
|
constraints |
array|null |
null |
Constraints to validate against, using the same syntax as Symfony's YAML validation mapping. If null, the input class metadata is used |
|
error_output_violations |
bool |
false |
Send the violations to the error output and skip the task instead of throwing an exception |
Constraints are built by CleverAge\ProcessBundle\Validator\ConstraintLoader: each constraint is a single-key map
ConstraintName: options. The name is either a short name of a Symfony built-in constraint (NotBlank, Collection,
...) or a FQCN. Options can contain nested constraints.
- Validate an entity with its own metadata (attributes, YAML mapping...) for the
importgroup
# Task configuration level
validate:
service: '@CleverAge\ProcessBundle\Task\Validation\ValidatorTask'
options:
groups: [import]
outputs: [save]- Validate an array with inline constraints and forward violations to an error branch
# Task configuration level
validate:
service: '@CleverAge\ProcessBundle\Task\Validation\ValidatorTask'
options:
log_errors: warning
error_output_violations: true
constraints:
- Collection:
allowExtraFields: true
fields:
sku:
- NotBlank: ~
price:
- Type: numeric
- PositiveOrZero: ~
outputs: [save]
error_outputs: [log_violations]