benrhine opened a new issue, #14575:
URL: https://github.com/apache/grails-core/issues/14575

   
   - [X] Steps to reproduce provided
   - [ ] Stacktrace (if present) provided
   - [X] Example that reproduces the problem uploaded to Github
   - [X] Full description of the issue provided (see below)
   
   ### Steps to Reproduce
   
   These steps are true wether using domain objects or general validated objects
   
   If you have a parent class and child class as follows 
   ```
   class Person implements Validateable {
       String name
   
       static constraints = {
           name nullable: false
       }
   }
   
   class Employer extends Person{
       String company
       List<Employee> employees
   
       static constraints = {
           company nullable: false
           employees minSize: 5
       }
   }
   ```
   
   If you call `.validate()` on an this `Employer child = new Employer(name: 
'TEST', company: 'TEST')` this will validate as true even when employees is 
null.
   
   If you call `.validate()` on an this ```Employer child = new Employer(name: 
'TEST', company: 'TEST')
               child.employees = [employee1]``` this will validate as false as 
employees are less than 5.
   
   If you call `.validate()` on an this ```Employer child = new Employer(name: 
'TEST', company: 'TEST')
               child.employees = [employee1, employee2, employee3, employee4, 
employee5]``` this well validate as true.
   
   ### Expected Behaviour
   
   That when employees is null, validation fails due to the minimum number not 
being met.
   
   ### Actual Behaviour
   
   That when employees is null, validation passes.
   
   Note: if you want to produce expected behaviour it is possible by adding 
`nullable: false`
   `employees nullable:false, minSize: 5`
   
   ### Environment Information
   
   - **Operating System: MacOS 10.13.3
   - **GORM Version: 6.1.9.RELEASE
   - **Grails Version (if using Grails): 3.3.4
   - **JDK Version: openjdk version "1.8.0_163"
   
   ### Example Application
   
   https://github.com/benrhine/validateableInheritence 
   
   You can see the issue in EmployerValidationIntSpec, which uses Person and 
Employer objects
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to