File tree Expand file tree Collapse file tree 6 files changed +40
-34
lines changed
io/avaje/http/hibernate/validator
resources/META-INF/services Expand file tree Collapse file tree 6 files changed +40
-34
lines changed Original file line number Diff line number Diff line change 22<project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
33 xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
44 <modelVersion >4.0.0</modelVersion >
5-
6- <groupId >io.avaje</groupId >
7- <artifactId >avaje-http-hibernate-validator</artifactId >
8- <version >3.5</version >
9-
105 <parent >
11- <groupId >org.avaje</groupId >
12- <artifactId >java11-oss</artifactId >
13- <version >4.3</version >
14- <relativePath />
6+ <groupId >io.avaje</groupId >
7+ <artifactId >avaje-http-parent</artifactId >
8+ <version >3.6-RC1</version >
159 </parent >
10+
11+ <artifactId >avaje-http-hibernate-validator</artifactId >
1612
1713 <scm >
1814 <developerConnection >scm:git:git@github.com:avaje/avaje-http.git</developerConnection >
3632 <dependency >
3733 <groupId >io.avaje</groupId >
3834 <artifactId >avaje-http-api</artifactId >
39- <version >2.6 </version >
35+ <version >3.6-RC1 </version >
4036 <scope >provided</scope >
4137 </dependency >
4238
4339 <dependency >
4440 <groupId >io.avaje</groupId >
45- <artifactId >avaje-inject</artifactId >
46- <version >11.0 </version >
41+ <artifactId >avaje-inject-generator </artifactId >
42+ <version >12.1-RC3 </version >
4743 <scope >provided</scope >
4844 </dependency >
4945
Original file line number Diff line number Diff line change 11package io .avaje .http .hibernate .validator ;
22
3- import java .util .*;
3+ import java .util .ArrayList ;
4+ import java .util .List ;
5+ import java .util .Set ;
46
57import io .avaje .http .api .ValidationException ;
68import io .avaje .http .api .ValidationException .Violation ;
79import io .avaje .http .api .Validator ;
810import jakarta .validation .ConstraintViolation ;
911import jakarta .validation .ConstraintViolationException ;
10- import jakarta .validation .Validation ;
11- import jakarta .validation .ValidatorFactory ;
1212
1313public class BeanValidator implements Validator {
1414
15- private static final ValidatorFactory factory = Validation .buildDefaultValidatorFactory ();
15+ private jakarta .validation .Validator validator ;
16+
17+ void postConstruct (jakarta .validation .Validator validator ) {
18+ this .validator = validator ;
19+ }
1620
1721 @ Override
18- public void validate (Object bean , String acceptLanguage , Class <?>... groups ) throws ValidationException {
19- final Set <ConstraintViolation <Object >> violations = factory .getValidator ().validate (bean , groups );
22+ public void validate (Object bean , String acceptLanguage , Class <?>... groups )
23+ throws ValidationException {
24+ final Set <ConstraintViolation <Object >> violations = validator .validate (bean , groups );
2025 if (!violations .isEmpty ()) {
2126 throwExceptionWith (violations );
2227 }
Original file line number Diff line number Diff line change 22
33import io .avaje .http .api .Validator ;
44import io .avaje .inject .BeanScopeBuilder ;
5+ import io .avaje .inject .spi .PluginProvides ;
6+ import jakarta .validation .Validation ;
57
6- /**
7- * Plugin for avaje inject that provides a default BeanValidator instance.
8- */
8+ /** Plugin for avaje inject that provides a default BeanValidator instance. */
9+ @ PluginProvides (Validator .class )
910public final class ValidatorProvider implements io .avaje .inject .spi .InjectPlugin {
1011
11- @ Override
12- public Class <?>[] provides () {
13- return new Class <?>[]{Validator .class };
14- }
15-
1612 @ Override
1713 public void apply (BeanScopeBuilder builder ) {
18- builder .provideDefault (null , Validator .class , BeanValidator ::new );
14+ builder .provideDefault (
15+ Validator .class ,
16+ () -> {
17+ var validator = new BeanValidator ();
18+ builder .addPostConstruct (
19+ b ->
20+ validator .postConstruct (
21+ b .getOptional (jakarta .validation .Validator .class )
22+ .orElseGet (
23+ () -> Validation .buildDefaultValidatorFactory ().getValidator ())));
24+ return validator ;
25+ });
1926 }
20- }
27+ }
Original file line number Diff line number Diff line change 22
33module io .avaje .http .hibernate .validator {
44
5- exports io .avaje .http .hibernate .validator ;
6-
7- requires io .avaje .http .api ;
8- requires io .avaje .inject ;
9- requires jakarta .validation ;
5+ requires transitive io .avaje .http .api ;
6+ requires transitive io .avaje .inject ;
7+ requires transitive jakarta .validation ;
108
119 provides io .avaje .inject .spi .InjectExtension with ValidatorProvider ;
1210}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 4949 <module >http-generator-javalin</module >
5050 <module >http-generator-sigma</module >
5151 <module >http-generator-client</module >
52+ <module >http-hibernate-validator</module >
5253 </modules >
5354
5455 <profiles >
You can’t perform that action at this time.
0 commit comments