Skip to content

Instantly share code, notes, and snippets.

@sergiomichels
Created December 12, 2013 10:49
Show Gist options
  • Save sergiomichels/7926195 to your computer and use it in GitHub Desktop.
Save sergiomichels/7926195 to your computer and use it in GitHub Desktop.
println grailsApplication.config.grails.databinding.useSpringBinder
Colaborador c = new Colaborador(nome: 'Sérgio Michels', dtAdmissao: '01/03/2007', dtNascimento: '11/10/1989', cpf: '020.234.920-92', matricula: 232040L)
c.validate()
println c.errors
Outputs:
true
grails.validation.ValidationErrors: 3 errors
Field error in object 'br.com.insoft4.ciweb.Colaborador' on field 'cpf': rejected value [020.234.920-92]; codes [typeMismatch.br.com.insoft4.ciweb.Colaborador.cpf,typeMismatch.cpf,typeMismatch.br.com.insoft4.core.types.PessoaIdentity,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [br.com.insoft4.ciweb.Colaborador.cpf,cpf]; arguments []; default message [cpf]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'br.com.insoft4.core.types.PessoaIdentity' for property 'cpf'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [br.com.insoft4.core.types.PessoaIdentity] for property 'cpf': no matching editors or conversion strategy found]
Field error in object 'br.com.insoft4.ciweb.Colaborador' on field 'dtNascimento': rejected value [11/10/1989]; codes [typeMismatch.br.com.insoft4.ciweb.Colaborador.dtNascimento,typeMismatch.dtNascimento,typeMismatch.org.joda.time.LocalDate,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [br.com.insoft4.ciweb.Colaborador.dtNascimento,dtNascimento]; arguments []; default message [dtNascimento]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.LocalDate' for property 'dtNascimento'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.joda.time.LocalDate] for property 'dtNascimento': no matching editors or conversion strategy found]
Field error in object 'br.com.insoft4.ciweb.Colaborador' on field 'dtAdmissao': rejected value [01/03/2007]; codes [typeMismatch.br.com.insoft4.ciweb.Colaborador.dtAdmissao,typeMismatch.dtAdmissao,typeMismatch.org.joda.time.LocalDate,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [br.com.insoft4.ciweb.Colaborador.dtAdmissao,dtAdmissao]; arguments []; default message [dtAdmissao]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.LocalDate' for property 'dtAdmissao'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.joda.time.LocalDate] for property 'dtAdmissao': no matching editors or conversion strategy found]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment