0

grailsでこのようなことをする正しい方法は何ですか:

class myDomainThing {
  String description
  MyOtherDomainThing otherThing

  static constraints = {
    description(nullable:if(otherThing))
    otherThing(nullable:if(description))
  }
}

したがって、otherDomainThingへのリンクがあるか、文字列の説明が必要です。

4

2 に答える 2

2

バリデーターを使用して Grails カスタム検証を使用する必要があります

static constraints = {
  description(validator: {
        return otherThing and !description
    })
}
于 2011-05-06T21:19:47.437 に答える
0

カスタムバリデーターを使用する必要があります

static constraints = {
  description validator: { val, obj -> 
     if(otherthing && val) {
         false
     }
     else {
       true
     }
  }
}

明らかにいくつかの疑似コードがそこにあるotherthing

于 2011-05-06T21:14:38.553 に答える