コマンド オブジェクトのフィールドを手動で検証したい
これでフィールドの最大値(および最小値)を取得できることはわかっています:
MyDomain.constraints.myField.getAppliedConstraint('max').maxValue
'myField' で 'validate' コマンドを実行してエラー オブジェクトを取得するにはどうすればよいですか?
コマンド オブジェクトのフィールドを手動で検証したい
これでフィールドの最大値(および最小値)を取得できることはわかっています:
MyDomain.constraints.myField.getAppliedConstraint('max').maxValue
'myField' で 'validate' コマンドを実行してエラー オブジェクトを取得するにはどうすればよいですか?
grails docsを見てください。
validate()
プロパティの定義済みリストでメソッドを使用できます。
if(!yourObject.validate(['myField'])) {
yourObject.errors.each {
println it
}
}