grails-data-mapping
grails-data-mapping copied to clipboard
minSize validation does not validate correctly on collections
Steps to Reproduce
- define following domain class
class mytest { def my_data = "123" static hasMany = [childItems: mytest] static constraints = { childItems minSize: 1 } } 2. execute the following code
def mytest = new mytest() mytest.save(failOnError: true, flush: true) def result = mytest.validate()
Expected Behaviour
According http://docs.grails.org/3.1.1/ref/Constraints/minSize.html
minSize: Sets the minimum size of a collection or number property
Hence result should be false
Actual Behaviour
result is true
Environment Information
- Operating System: Ubuntu 16.04
- GORM Version: gormVersion=6.1.10.RELEASE
- Grails Version (if using Grails): 3.3.8
- JDK Version: 1.8.0_201
If minSize
is set to 2 and you add just 1 item, does validation fail?
If
minSize
is set to 2 and you add just 1 item, does validation fail?
Yes it fails as expected. Guess you know why you are asking ;-)
Guess you know why you are asking
Correct.