Monday, March 17, 2008

Constraint in Grails

Grails use constraint key word for Domain class's constraint.As a note,I summary the constraint in Grails Domain Model.





























































































NameExampleDescription
blanktitle(blank:false)Set to false if a string value cannot be blank
emailemail(email:true)Set to true if the value must be an email address
inListsex(inList:['Man','Woman'])Value must be contain within the given list
lengthtitle(length:1..50)Use a range value to restrict the length of string or range
minage(min:new Date()Set the minimun value
minLengthtitle(minLength:5)Set the minimum length of a string or array property
minSizechildren(minSize:10)Set the minimum size of a collection or number property
matchesname(matches:/[a-zA-Z]/)Matches the supplied regular expression
maxage(max:new Date()Set the maximum value
maxLengthtitle(maxLength:5)Set the maximum length of a string or array property
maxSizechildren(maxSize:10)Set the maximum size of a collection or number property
notEqualname(notEqual:'Eric')Must not equal the special value
nullablenameSet to false if property value cannot be null
rangeage(range:30..60)Must occur within the special range
sizechildren(size:5..15)Use a range to restrict the size of a collection or number
uniquename(unique:true)Set to true if the property must be unique
urlurl(url:true)Set to true if a string value is a url address

No comments: