-
Notifications
You must be signed in to change notification settings - Fork 582
Helidon Declarative Validation #10755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tomas-langer
wants to merge
17
commits into
helidon-io:main
Choose a base branch
from
tomas-langer:10735-validation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+15,559
−201
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f1a274e to
f7ee02b
Compare
Verdent
requested changes
Oct 15, 2025
.../codegen/src/main/java/io/helidon/declarative/codegen/validation/ValidatedTypeGenerator.java
Outdated
Show resolved
Hide resolved
.../codegen/src/main/java/io/helidon/declarative/codegen/validation/ValidatedTypeGenerator.java
Outdated
Show resolved
Hide resolved
.../codegen/src/main/java/io/helidon/declarative/codegen/validation/ValidatedTypeGenerator.java
Outdated
Show resolved
Hide resolved
New module, fixes to codegen to support all required features (such as annotations on type declaration)
passes tests, checkstyle, spotbugs and copyright
…the machine, and cannot be changed
Removed as much as possible that can be hidden in the implementation from the public API. Added module to error handle validation exception into a bad request status code
06b0271 to
1a30719
Compare
|
Examples of generated files:
ValidatedType__Validated.java |
…issing dependencies. This resolves a pipeline build issue, where a module could be compiled before the codegen itself.
Verdent
previously approved these changes
Oct 22, 2025
danielkec
reviewed
Oct 23, 2025
codegen/class-model/src/main/java/io/helidon/codegen/classmodel/ImportOrganizer.java
Show resolved
Hide resolved
danielkec
reviewed
Oct 23, 2025
codegen/class-model/src/main/java/io/helidon/codegen/classmodel/ImportOrganizer.java
Show resolved
Hide resolved
|
Using Oracle DB lite for test of Helidon data hoping that it shortens the time to run the pipeline, as it was timing out |
2059dea to
21733c6
Compare
21733c6 to
43bbfc4
Compare
- use new addContentLine() method in content builder - remove wrong renaming - remove wrong public modifier from package private classes
Verdent
approved these changes
Nov 3, 2025
danielkec
approved these changes
Nov 5, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
4.x
Version 4.x
bean validation
declarative
Helidon Declarative
OCA Verified
All contributors have signed the Oracle Contributor Agreement.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #10735
validation/tests/validation/src/test/java/io/helidon/validation/tests/validation/ValidationTest.java
and
validation/tests/validation/src/test/java/io/helidon/validation/tests/validation/ValidatorTest.java
for usage (not really examples, but what I am testing right now)
Declarative Validation
Validation provides capabilities to validate types and method parameters/return values.
Both features require code-generation.
Type validation code-generation of type validators is triggered by the presence of the
@Validation.Validatedannotation on a type.Method validation code-generation of interceptors is triggered by the presence of an annotation "meta-annotated"
with
@Validation.Constrainton a method, its parameter, or type arguments of its parameters or return type.In addition the
Check.Validannotation also triggers code-generation, and can be used to validate against a type validatormentioned above.
Declaration
Annotations:
io.helidon.validation.Validationclass to trigger validation using an interceptor (all meta-annotated with@Validation.Constraint)@Validation.Validated- on a type to generate type validator for a typeConfiguration
There is currently no configuration for validation.
Implementation
Each constraint has a dedicated validator provider service, with (default-weight - 30) weight.
The providers are annotated with a named annotation that matches the constraint annotation.
This allows our users to override the implementation using their custom services.
The validation process works as follows:
ValidationExceptionif validation failsThe type validation works as follows:
@Validation.ValidatedannotationImportant types:
Validation- a container class for validation annotationsValidationException- throws when validation fails in an interceptorValidator- programmatic API to validate instances and their properties (only for validated types), can be obtained from service registryConstraintValidatorProvider- service registry service that validates a single constraint annotation typeConstraintValidator- created for each annotated element using the type of the element and the constraint annotationvalidatorspackage contains built-in constraint validator providersSupported concepts:
@Validation.Validis a constraint annotationOptional,Map,Collection- i.e.List<@Validation.String.NotBlank String>will trigger an interceptor and will be validated@Validation.Validatedwill be validated when used in a method or constructor that uses@Validation.Validon the typed parameterfields, and type arguments
if the element was directly annotated with the constraints
@Validation.Constraint), such annotationsmay also be meta-annotated with additional constraints; a custom constraint annotation requires a custom validator provider