Thursday, 22 August 2013

Where to change i18n default messages of client side in Grails?

Where to change i18n default messages of client side in Grails?

I have the next constraint in my domain object usuario/Usuario.groovy:
phone blank: false, matches: "[0-9 -+()]{3,15}"
And I have in *i18n/messages_es.properties*:
usuario.telefono.matches=Se admiten números, espacios y los caracteres:
-+(). Se admiten entre 3 y 15 caracteres en total.
This is the error message if the phone doesn't match the pattern:

The translation of the message would be something like: "Please, adjust
the requested format"
I have not any similar error message in any of the i18n/messages... files.
It looks a client side error message as it appears instantly.
In create gsp there is the next code (I think the error message could come
from here):
<g:hasErrors bean="${usuarioInstance}">
<bootstrap:alert class="alert-error">
<ul>
<g:eachError bean="${usuarioInstance}" var="error">
<li <g:if test="${error in
org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
error="${error}"/></li>
</g:eachError>
</ul>
</bootstrap:alert>
</g:hasErrors>
How could I change this error message by a custom one?

No comments:

Post a Comment