次のドメイン クラスがあります。
class UserAccount {
String userName
String password
String confirmPassword
static transients = ['confirmPassword']
static constraints = {
userName blank: false, nullable: false
password blank: false, nullable: false
userName(unique: true)
password(password: true)
password(blank: false, nullable: false, size:5..20, validator: {password, obj ->
def confirmPassword= obj.properties['confirmPassword']
//println(confirmPassword)
confirmPassword== password ? true : ['invalid.matchingpasswords']
} )
}
}
このクラスでは as と宣言confirmPassword
しましtransients
たが、confirmPasswordNULL
はフォームの送信時に a のみを出力します。
<g:field type="password" name="confirmPassword" required="" value="${userAccountInstance?.confirmPassword}"/>
を削除するとtransients
、正常に動作しますが、データベースにこの値が必要ないため、 を使用しtransients
ました。
ここで検証を行う別の方法はありますか?