Skip to content

Commit e7bb544

Browse files
authored
Merge pull request #1 from SentryMan/main
initial commit
2 parents 66e543c + b4ae1c8 commit e7bb544

32 files changed

+1747
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
target/
2+
build/
3+
.idea/
4+
*.iml
5+
.gradle
6+
*.prefs
7+
*.classpath
8+
*.project
9+
*.class
10+
.DS_Store

blackbox-test/pom.xml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>io.avaje</groupId>
6+
<artifactId>avaje-jsonb-parent</artifactId>
7+
<version>1.5-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>validator-blackbox-test</artifactId>
11+
<name>validator blackbox test</name>
12+
<description>test module</description>
13+
14+
<properties>
15+
<maven.deploy.skip>true</maven.deploy.skip>
16+
<java.release>17</java.release>
17+
</properties>
18+
19+
<dependencies>
20+
21+
<!-- for testing fields with third party annotations -->
22+
<dependency>
23+
<groupId>javax.validation</groupId>
24+
<artifactId>validation-api</artifactId>
25+
<version>2.0.1.Final</version>
26+
</dependency>
27+
28+
<dependency>
29+
<groupId>io.avaje</groupId>
30+
<artifactId>avaje-jsonb</artifactId>
31+
<version>1.5-SNAPSHOT</version>
32+
</dependency>
33+
34+
<!-- <dependency>-->
35+
<!-- <groupId>io.avaje</groupId>-->
36+
<!-- <artifactId>avaje-jsonb-jackson</artifactId>-->
37+
<!-- <version>0.15-SNAPSHOT</version>-->
38+
<!-- </dependency>-->
39+
40+
<dependency>
41+
<groupId>io.avaje</groupId>
42+
<artifactId>avaje-jsonb-generator</artifactId>
43+
<version>1.5-SNAPSHOT</version>
44+
<scope>provided</scope>
45+
</dependency>
46+
47+
<!-- test dependencies -->
48+
49+
<dependency>
50+
<groupId>io.avaje</groupId>
51+
<artifactId>junit</artifactId>
52+
<version>1.1</version>
53+
<scope>test</scope>
54+
</dependency>
55+
56+
</dependencies>
57+
58+
59+
<build>
60+
<plugins>
61+
<plugin>
62+
<artifactId>maven-deploy-plugin</artifactId>
63+
<configuration>
64+
<skip>true</skip>
65+
</configuration>
66+
</plugin>
67+
<plugin>
68+
<artifactId>maven-javadoc-plugin</artifactId>
69+
<configuration>
70+
<skip>true</skip>
71+
</configuration>
72+
</plugin>
73+
</plugins>
74+
</build>
75+
76+
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.example.customer.customtype.CustomTypeComponent
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[
2+
{
3+
"id": 1,
4+
"name": "n0",
5+
"skip_string": "234"
6+
},
7+
{
8+
"id": 2,
9+
"name": "n1",
10+
"skip_int": 139
11+
},
12+
{
13+
"id": 3,
14+
"name": "n2",
15+
"skip_dec": 895.34
16+
},
17+
{
18+
"id": 4,
19+
"node_id": "MDEwOlJlcG9zaXRvcnkxNTc2MDI1Mw==",
20+
"name": "n3",
21+
"skip_object": {
22+
"id": 208973,
23+
"node_id": "MDQ6VXNlcjIwODk3Mw=="
24+
}
25+
},
26+
{
27+
"id": 5,
28+
"name": "n4",
29+
"skip_array": [1,2,3,4]
30+
},
31+
{
32+
"id": 6,
33+
"name": "n5",
34+
"skip_null": null
35+
},
36+
{
37+
"id": 7,
38+
"name": "n6",
39+
"skip_true": true
40+
},
41+
{
42+
"id": 8,
43+
"name": "n7",
44+
"skip_false": false
45+
},
46+
{
47+
"id": 9,
48+
"skip_string": "234",
49+
"name": "n8"
50+
}
51+
]

pom.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.avaje</groupId>
6+
<artifactId>java11-oss</artifactId>
7+
<version>3.9</version>
8+
</parent>
9+
10+
<groupId>io.avaje</groupId>
11+
<artifactId>avaje-validator-parent</artifactId>
12+
<version>1.5-SNAPSHOT</version>
13+
14+
<packaging>pom</packaging>
15+
<name>validator parent</name>
16+
<description>parent pom for validator</description>
17+
18+
<scm>
19+
<connection>scm:git:[email protected]:avaje/avaje-validator.git</connection>
20+
<developerConnection>scm:git:[email protected]:avaje/avaje-validator.git</developerConnection>
21+
<tag>avaje-validator-parent-1.1</tag>
22+
</scm>
23+
24+
<properties>
25+
<surefire.useModulePath>false</surefire.useModulePath>
26+
<nexus.staging.autoReleaseAfterClose>true</nexus.staging.autoReleaseAfterClose>
27+
</properties>
28+
29+
<modules>
30+
<module>validator</module>
31+
</modules>
32+
33+
<profiles>
34+
<profile>
35+
<id>central</id>
36+
</profile>
37+
<profile>
38+
<id>default</id>
39+
<activation>
40+
<activeByDefault>true</activeByDefault>
41+
</activation>
42+
<modules>
43+
<module>blackbox-test</module>
44+
</modules>
45+
</profile>
46+
</profiles>
47+
48+
</project>

validator/pom.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>io.avaje</groupId>
6+
<artifactId>avaje-validator-parent</artifactId>
7+
<version>1.5-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>avaje-validator</artifactId>
11+
<name>validator</name>
12+
13+
<dependencies>
14+
15+
<dependency>
16+
<groupId>io.avaje</groupId>
17+
<artifactId>avaje-inject</artifactId>
18+
<version>9.0</version>
19+
<scope>provided</scope>
20+
<optional>true</optional>
21+
</dependency>
22+
23+
<dependency>
24+
<groupId>jakarta.validation</groupId>
25+
<artifactId>jakarta.validation-api</artifactId>
26+
<version>3.0.2</version>
27+
</dependency>
28+
29+
30+
<dependency>
31+
<groupId>io.avaje</groupId>
32+
<artifactId>junit</artifactId>
33+
<version>1.1</version>
34+
<scope>test</scope>
35+
</dependency>
36+
37+
</dependencies>
38+
39+
</project>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package io.avaje.validation;
2+
3+
import static java.lang.annotation.RetentionPolicy.CLASS;
4+
5+
import java.lang.annotation.ElementType;
6+
import java.lang.annotation.Retention;
7+
import java.lang.annotation.Target;
8+
9+
/**
10+
* Marks a type for JSON support.
11+
*
12+
* <h3>Examples:</h3>
13+
*
14+
* <pre>{@code
15+
*
16+
* @ValidPojo(naming = LowerHyphen)
17+
* public class Customer ...
18+
*
19+
* }</pre>
20+
*
21+
* <pre>{@code
22+
*
23+
* @ValidPojo
24+
* public record Product( ... )
25+
*
26+
* }</pre>
27+
*/
28+
@Retention(CLASS)
29+
@Target(ElementType.TYPE)
30+
public @interface ValidPojo {
31+
32+
/**
33+
* Specify types to generate JsonAdapters for.
34+
* <p>
35+
* These types are typically in an external project / dependency or otherwise
36+
* types that we can't or don't want to explicitly annotate with {@code @ValidPojo}.
37+
* <p>
38+
* Typically, we put this annotation on a package.
39+
*
40+
* <pre>{@code
41+
*
42+
* @ValidPojo.Import({Customer.class, Product.class, ...})
43+
* package org.example.processor;
44+
*
45+
* }</pre>
46+
*/
47+
@Retention(CLASS)
48+
@Target({ElementType.TYPE, ElementType.PACKAGE})
49+
@interface Import {
50+
51+
/**
52+
* Specify types to generate ValidPojo Adapters for.
53+
*/
54+
Class<?>[] value();
55+
}
56+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (C) 2014 Square, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.avaje.validation;
17+
18+
import java.lang.reflect.Type;
19+
import java.util.Set;
20+
21+
import io.avaje.validation.stream.ConstraintViolation;
22+
23+
/** The core API for serialization to and from json. */
24+
public interface ValidationAdapter<T> {
25+
26+
/** */
27+
void validate(T value, Set<ConstraintViolation> violations);
28+
29+
/** Factory for creating a ValidationAdapter. */
30+
public interface Factory {
31+
32+
/**
33+
* Create and return a ValidationAdapter given the type and annotations or return null.
34+
*
35+
* <p>Returning null means that the adapter could be created by another factory.
36+
*/
37+
ValidationAdapter<?> create(Type type, Validator jsonb);
38+
}
39+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.avaje.validation;
2+
3+
import java.util.Set;
4+
5+
import io.avaje.validation.stream.ConstraintViolation;
6+
7+
8+
public interface ValidationType<T> {
9+
10+
Set<ConstraintViolation> validate(T object);
11+
12+
void validate(T object, Set<ConstraintViolation> violations);
13+
}

0 commit comments

Comments
 (0)