I have a working Form, it has a required field that needs to be notBlank:
/**
* @Assert\NotBlank
*/
private $field1 = '';
If I specify this field in the request, but leave the field empty, I get this response:
{
"code":400,
"message":"Validation Failed",
"errors":{
"children":{
"field1":{
"errors":["Field should not be blank"]
}
}
}
}
If I omit this field from the request, I get this response:
{
"code":400,
"message":"Validation Failed",
"errors":{
"errors":["Field should not be blank"]
}
}
Is there some built-in Symfony logic somewhere that I can use to make the second example match the first example?
[edit] Was using Symfony 2.5 - now updated to Symfony 2.8.3, same problem.
This behavior can occur when the field is not presented in the form object itself. In this case violation mapper can't map validation error to one of the fields. Please check that the field is presented in the form object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With