jdaugherty opened a new pull request, #16624:
URL: https://github.com/apache/grails-core/pull/16624

   A domain class carrying a jakarta.validation annotation is validated by 
Hibernate Validator through GormValidatorAdapter, which until now replaced 
GORM's own validator entirely: the constraints block was ignored for validation 
while it still defined the schema, the validator exposed no constraint metadata 
(it was not a ConstrainedEntity, so constrainedProperties was empty for 
scaffolding and plugins), null values were never reached by @NotNull and 
friends because the traversable resolver treated a null property as 
uninitialized, class level constraints were skipped for the same reason, and 
the unit test datastore ignored the annotations altogether.
   
   GormValidatorAdapter now also runs the PersistentEntityValidator of the 
entity, with the GORM nullable constraint relaxed for properties whose 
nullability is declared by an annotation so a null value is reported once, and 
implements ConstrainedEntity with the constraints block merged with a 
description of the annotations as GORM constraints 
(JakartaConstraintsTranslator). Bean Validation no longer cascades when the 
GORM validator does, so associations are validated once. 
JakartaValidatorRegistry caches the validator per entity. 
MappingContextTraversableResolver treats a null value and a class level node as 
reachable. DataTest creates the same combined validator for annotated domain 
classes.
   
   Documented in a new Bean Validation Annotations section of the validation 
guide and in the 8.0.x upgrade notes.
   
   I'm viewing this as a 'bug' but it could be argued to be a feature. I'm ok 
moving this to 9.0 if this fix is deemed a problem. 
   


-- 
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