[java-gen] Support Min/Max/Pattern javax.validation.constraints
See original GitHub issueIs your enhancement related to a problem? Please describe
I noticed that required
fields get a @NotNull
annotation applied, but there are other supported validation patterns that can be applied to generated Java models as well
https://javaee.github.io/tutorial/bean-validation002.html
Describe the solution you’d like
Examples
Mapped to
@Min(0)
@Max(1000)
Mapped to
@Pattern(...)
Describe alternatives you’ve considered
Manually adding these where they would be needed.
Additional context
The objects will fail to be constructed if an invalid value is provided when the annotations are present.
Use-case: Preventing bad user-provided input fields into an API layer.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:25 (10 by maintainers)
Top Results From Across the Web
21.1 Using Bean Validation Constraints
Constraints can be built in or user defined. User-defined constraints are called custom constraints. Several built-in constraints are available in the javax.
Read more >Package javax.validation.constraints - Java EE
Defines several DecimalMin annotations on the same element. Digits. The annotated element must be a number within accepted range Supported types are: BigDecimal ......
Read more >Java Bean Validation Basics - Baeldung
Learn how to validate domain objects in Spring Boot using Hibernate Validator, the reference implementation of the Bean Validation framework.
Read more >java - Why do bean validation Min/Max constraints not support ...
Use the @DecimalMin annotation. You will need to pass a literal String value, because the attrubute value must be constant (String.
Read more >Bean validation built-in constraints - IBM
The Bean Validation API is supported by constraints that are primarily ... are available in the javax.validation.constraints package.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fine by me. Moving discussion to https://github.com/fabric8io/kubernetes-client/issues/4384
@andreaTP new issue opened