in the controller
params.max = Math.min(params?.max?.toInteger() ?: 10, 20)
params.offset = params?.offset?.toInteger() ?: 0
if you enter in the following urls
/books?offset=10&max= //error
/books?offset=10&max=sdf //error
/books?offset=&max=10 //works
/books?offset=adsfa&max=10 //error
java.lang.NumberFormatException: For input string: "asdf"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.valueOf(Integer.java:554)
Is there a one line groovy answer to check against null/string characters in the url params?