Answer the question
In order to leave comments, you need to log in
Symfony 3 Validation - how to make mutually exclusive validations?
Used by Symfony/Validation as a separate component, the rest of the environment has no other Symfony components.
There is a form, in the form of a drop-down list. The default value is empty.
You need to check the incoming data for an empty value - return the error "Select a value from the list", or, if it is not empty - return the error "Value *** is not in the list".
Validation only on the value of the variable.
Design on the backend in the style of php code (not annotations, not xml / yaml).
Like this now
$errors = $validator->validate(
$value,
[
new NotBlank(
[
'message' => 'Выберите значение из списка'
]
),
new Choice(
[
'choices' => $valuesList,
'message' => 'Значение {{ value }} отсутствует в списке'
]
)
]
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question