@@ -27,7 +27,7 @@ import io.jooby.hibernate.validator.HibernateValidatorModule;
2727import io.jooby.hibernate.validator.HibernateValidatorModule
2828
2929{
30- install(new HibernateValidatorModule())
30+ install(HibernateValidatorModule())
3131}
3232----
3333
@@ -102,17 +102,15 @@ class Controller {
102102
1031034) Usage in in script/lambda routes
104104
105- Jooby doesn't provide fully native bean validation in script/lambda at the moment,
106- but you can use a helper that we utilize under the hood in MVC routes:
107-
108105.Java
109106[source, java, role="primary"]
110107----
111108import io.jooby.validation.BeanValidator;
112109
113110{
111+ use(BeanValidator.validate());
114112 post("/validate", ctx -> {
115- Bean bean = BeanValidator.validate( ctx, ctx .body(Bean.class) );
113+ Bean bean = ctx.body(Bean.class);
116114 ...
117115 });
118116}
@@ -124,8 +122,9 @@ import io.jooby.validation.BeanValidator;
124122import io.jooby.validation.BeanValidator
125123
126124{
125+ use(BeanValidator.validate())
127126 post("/validate") {
128- val bean = BeanValidator.validate( ctx, ctx.body(Bean.class) )
127+ val bean = ctx, ctx.body(Bean.class)
129128 ...
130129 }
131130}
@@ -134,6 +133,21 @@ import io.jooby.validation.BeanValidator
134133`BeanValidator.validate()` behaves identically to validation in MVC routes.
135134It also supports validating list, array, and map of beans
136135
136+ There is a handler version of it, so you can apply per route:
137+
138+ .validate
139+ [source, java]
140+ ----
141+ import io.jooby.validation.BeanValidator.validate;
142+
143+ {
144+ post("/validate", validate(ctx -> {
145+ Bean bean = ctx.body(Bean.class);
146+ ...
147+ }));
148+ }
149+ ----
150+
137151=== Constraint Violations Rendering
138152
139153`HibernateValidatorModule` provides default built-in error handler that
0 commit comments