Announcement Announcement Module
No announcement yet.
Validating Command Objects Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validating Command Objects

    Hi folks,

    i'm just upgrading to Grails 2.0 and i have a strange compile error:

    This is my command object:
    class InputController {
    Date datum;
    String lieder;

    static constraints = {
    datum(blank:false, nullable:false)
    lieder(blank:false, validator : {
    def words = it.split(/\s+/)
    boolean allRight = true
    def errors = []
    if ( it && !(it ==~ /(\D{0,2})(\d+)(\D*)/)) {
    allRight = false; errors << it
    def retValue = ['invalid.pattern'] + errors.join(', ')
    if (!allRight) return retValue

    And this is the error i get:
    C:\Users\dietmar\Documents\NetBeansProjects\Liedve rwaltung\grails-app\controllers\LiedController.groovy: -1: The return type of java.lang.Object getErrors() in InputController$__clinit__closure1_closure2_closur e3 is incompatible with org.springframework.validation.Errors getErrors() in groovy.lang.Closure
    . At [-1:-1] @ line -1, column -1.

    If i comment out the validation code the compile errror is gone. I think my implementation is according to the documentation. With Grails 1.3.x there was no compilation error, and the app was running correctly.

    Can someone help me?

    My best regards

  • #2
    This forum seems to be not very busy