I have following constraints on two integers, score and numOfQuestions.
score blank:false, min:1, nullable:false, notEqual:null
numOfQuestions blank:false, min:1, nullable:false, notEqual:null
As it can be seen I want these fields to be greater then 0 and should not be null or blank but regardless of what I do, rather then showing a friendly message like “property can not be blank” my screen gets filled with long exception…
Is there any other way to validate integers for non blank inputs?
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]
I have seen this http://jira.grails.org/browse/GRAILS-4603 but didn’t help much
I think you can replace the constraints above with just:
Because
min:1implies not-null. The constraintblank: falsecan only be applied toStringproperties, so you’re use of this constraint with a numeric property is probably responsible for the exception you’re seeing.