-
Notifications
You must be signed in to change notification settings - Fork 55
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
Annotation to provide validation features on top of types #239
Comments
This can also be useful in conjunction with automated data mapping.
|
+1. |
Looking from just data mapping point of view, statistics such as mean, standard deviation etc also useful ( for numerical fields). Also, another angle is that although user does not provide this, in Choreo, we can trace, measure, and annotate in the background. |
This is potentially relevant to GraphQL. Simple types with validation constraints can be exposed as user-defined scalars. |
I think we should perhaps do this in a more first-class way using refinement types #238. |
@shafreenAnfar mentions JSR 303 https://beanvalidation.org/1.0/spec/ |
Yes. And Bean Validation 2.0 is available under https://beanvalidation.org/2.0/spec/ (formerly JSR 380). I feel Bean validation is an integral part of writing REST APIs with Spring Boot. The list of built-in constraints can be found here. |
We could get quite a lot of mileage from a simple
@validate
annotation with fields describing the kinds of validation to perform, e.g.For numeric types we could follow XML Schema part 2 and allow:
Other obvious things:
A more general and sophisticated way of doing this would be refinement types (#238), but that is orders of magnitude more work.
This doesn't deal with cases where you really want to transform the data as well notably:
The text was updated successfully, but these errors were encountered: