I use Doctrine 2 and Symfony 2 Validator Component (standalone, without Forms Component).
So, when I finish checking the Doctrine Entity and pass it to SF2 Validator, I need to add custom error message to the validator. How can I do that?
This is my code so far:
$validator = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator();
$errors = $validator->validate($entry);
// Add custom error will be here
$errors->add(new ConstraintViolation("Error text maybe here"));