2012-02-14 12 views
0

私はscoreとnumOfQuestionsという2つの整数に以下の制約を課しています。私がこれらのフィールドが0より大きいになりたいとNULLまたは空白関係なく、私はむしろ、その後のような優しいメッセージを示す、何の「プロパティは空白にすることはできません」すべきではない見ることができるようにintカラムスローに対するGrails制約制約java.lang.IllegalArgumentException

score blank:false, min:1, nullable:false, notEqual:null 
numOfQuestions blank:false, min:1, nullable:false, notEqual:null 

私画面が長い例外でいっぱいになる... 空白以外の入力に対して整数を検証する他の方法はありますか?

Failed to convert property value of type java.lang.String to required type int for property numOfQuestions; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [int] for property numOfQuestions: PropertyEditor [org.springframework.beans.propertyeditors.CustomNumberEditor] returned inappropriate value of type [null] 

私はこのhttp://jira.grails.org/browse/GRAILS-4603を見てきましたが、私はあなただけで上記の制約に置き換えることができると思うくらい

答えて

-1

を助けなかった:

score min:1 
numOfQuestions min:1 

min:1は、nullでない意味しますので。 blank: falseという制約は、Stringのプロパティにしか適用できないため、この制約を数値プロパティで使用すると、おそらく例外が発生します。

+0

プラス 'nullable:false'がデフォルトであるため、指定は冗長です。 –

+0

@BurtBeckwithねえなぜそれが動作していないのか分かりませんが、私が持っているこの例外はすべて最低限です:制約が1です!プロパティーポイントのjava.lang.String型のプロパティ値を必須の型intに変換できませんでした。ネストされた例外はjava.lang.IllegalArgumentExceptionです:プロパティポイントの[java.lang.String]型の値を必須型[int]に変換できません:PropertyEditor [org.springframework.beans.propertyeditors.CustomNumberEditor]が[null型の不適切な値を返しました] – Sap

+0

'score'の可変型は何ですか? –