Annotations for validations
See original GitHub issueHello everyone!
Recently faced the need for validation and would like to be able to embed annotations in your code-generating library. Actually, an idea for development
For example: proto:
message Test {
// Validated:min=4,regexp=[a-d_1-5]+,max=145
string field1 = 1;
}
kotlin:
data class Test (
@field:Size(min=4, max=145)
@field:Pattern(regexp="[a-d_1-5]+")
val field1: String?
) {
....
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Java Bean Validation Basics - Baeldung
4. Using Validation Annotations · @NotEmpty validates that the property is not null or empty; can be applied to String, Collection, Map or...
Read more >Validation with Spring Boot - the Complete Guide - Reflectoring
The @Validated annotation is a class-level annotation that we can use to tell Spring to validate parameters that are passed into a method...
Read more >Validation Annotation - Apache Struts
Validation annotation must be applied at Type level. Parameters. validations - list of validations to apply. Examples. An Annotated Interface. Apply standard or ......
Read more >javax.validation.constraints (Java(TM) EE 7 Specification APIs)
Package javax.validation.constraints ; AssertTrue.List. Defines several AssertTrue annotations on the same element. ; DecimalMax. The annotated element must be a ...
Read more >Spring Boot - Creating a Custom Annotation for Validation
While I was working on a Spring Boot Project, I found that custom annotations were being used for validation. The best way to...
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
Hi @kubitre. We have the exact same need for validation in our REST API backend and are currently working on this. This will probably be available in the 0.9.0 release.
It’ll be implemented using protobuf custom options (see https://github.com/streem/pbandk/issues/65). You can see an example of using custom options for validation in https://github.com/envoyproxy/protoc-gen-validate. That tool doesn’t support Kotlin or pbandk, but it should give you an idea for how the validation rules could be implemented once #65 is done.
Closing this issue since the initial support for annotations has been implemented. Please open a new issue with additional details if what’s implemented does not fully address your needs.