Validation trait problem
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
The validation is broken when inheriting an object using Validatable trait.
Scenario:
- Groovy class DomainObject implements Validatable
- Groovy class Child extends DomainObject
Validation is not working for the Child class. With the following error -
```
groovy.lang.MissingMethodException: No signature of method: test.Child.findConstraintsEvaluator() is applicable for argument types: () values: []
test.Child@7e6b0c71
" type="org.spockframework.runtime.ConditionFailedWithExceptionError">Condition failed with Exception:
obj.validate()
| |
| groovy.lang.MissingMethodException: No signature of method: test.Child.findConstraintsEvaluator() is applicable for argument types: () values: []
test.Child@7e6b0c71
at test.DomainValidationSpec.simple validation test(DomainValidationSpec.groovy:18)
Caused by: groovy.lang.MissingMethodException: No signature of method: test.Child.findConstraintsEvaluator() is applicable for argument types: () values: []
at grails.validation.Validateable$Trait$Helper.validate(Validateable.groovy:159)
at grails.validation.Validateable$Trait$Helper.validate(Validateable.groovy:93)
... 1 more
```
The work around this problem is to add a dynamic method to the Object class. The issue is masked in a typical Grails project by injecting various dynamic methods used in the web framework codecs.
Workaround -
`Object.metaClass.dummy = {}`
### Steps to Reproduce
Executed DomainValidationSpec in the attached project.
### Expected Behaviour
The test should succeed.
### Actual Behaviour
Fails with the exception above.
### Environment Information
- **Operating System**: Windows
- **Grails Version:** 3.3.2
- **JDK Version:** 1.8
### Example Application
https://github.com/rogovskiy/grails-trait-issue
Contributor guide
Assessment
This issue has not been assessed yet.