phax / ph-jaxb-plugin

JAXB 4.x plugin that adds some commonly needed functionality
Apache License 2.0
4 stars 3 forks source link

Bean validation #1

Closed zsenyeg closed 5 years ago

zsenyeg commented 5 years ago

Hey,

I would like to use bean validation feature of this plugin, but as i testing it, it seems bean validation annotations is not complete. Bean validation (JSR-303) needs @Valid to perform cascaded bean validation on nested objects. I checked the source code, and @Valid is missing from the plugin.

Can you annotate all xs:ComplexType with @Valid?

Best regards,

Zsolt

phax commented 5 years ago

Hi Zsolt, thanks for pointing this out. Is the question fromhttps://stackoverflow.com/questions/5142065/jsr-303-valid-annotation-nested-object-not-working what you are targeting for? The accepted answer is:

You need to decorate addresses member of UserAddressesForm with @Valid annotation. See section 3.1.3 and 3.5.1 of JSR 303: Bean Validation. As I explained in my answer to the question Is there a standard way to enable JSR 303 Bean Validation using annotated method, this is the real use of @Valid annotation as per JSR 303.

Thanks, Philip

zsenyeg commented 5 years ago

Hey Philip,

First, thanks for your quick response. I checked your last commit, and it's just a part of what i'm targeting for.

https://huynt.wordpress.com/2012/08/09/jsr-303-bean-validation-nested-validation/

This is a really old post, but the bean validation did not change since, as i experienced it.

Thanks, Zsolt

phax commented 5 years ago

Hi Zsolt, I added another possibility, so that @Valid is created also on all members who's type are part of the code generation run. Does that now suffice? // Philip

zsenyeg commented 5 years ago

Hey Philip,

Thanks for the upgrade, i will check it soon.

Cheers, Zsolt

phax commented 5 years ago

So did you already come to a conclusion? If positive, I will try to release asap.

zsenyeg commented 5 years ago

Hey Philip,

I've tested your modification, and cascaded bean validation is working now properly.

I've tested your plugin with org.jvnet.jaxb2.maven2:maven-jaxb22-plugin:0.14.0 and org.codehaus.mojo:jaxws-maven-plugin:2.5 and the plugin was worked well with both.

I appreciate your work and your quick reactions m8. I'm waiting for the release.

Thanks and cheers, Zsolt

phax commented 5 years ago

Hi Zsolt, great that it worked out. ph-jaxb22-plugin 2.3.1.2 is on Maven central.