How to change message for validation constraint in Symfony globally?

484 views Asked by At

Is there a way to change the basic validation error message to one I need for all entities at once? Currently using Yaml config for every entity, but it's not a way.

CF\MyBundle\Entity\User:
  properties:
    email:
      - Email:
          message: e-mail no válido
      - NotBlank:
          message: Campo obligatorio
    username:
      - NotBlank:
          message: Campo obligatorio
1

There are 1 answers

0
xdazz On BEST ANSWER

The easiest way is to define an translations file.

# app/Resources/translations/validators.es.yml
This value should not be blank.: Campo obligatorio
This value is not a valid email address.: e-mail no válido