Skip to content

Commit a2d467e

Browse files
committed
package-infos
1 parent 80f9083 commit a2d467e

File tree

8 files changed

+59
-29
lines changed

8 files changed

+59
-29
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# [Avaje Validator](https://avaje.io/validator/)
22

3+
[![Discord](https://img.shields.io/discord/1074074312421683250?color=%237289da&label=discord)](https://discord.gg/Qcqf9R27BR)
34
[![Build](https://github.com/avaje/avaje-validator/actions/workflows/build.yml/badge.svg)](https://github.com/avaje/avaje-validator/actions/workflows/build.yml)
5+
[![native image build](https://github.com/avaje/avaje-validator/actions/workflows/native-image.yml/badge.svg)](https://github.com/avaje/avaje-validator/actions/workflows/native-image.yml)
46
[![Maven Central : avaje-validator](https://img.shields.io/maven-central/v/io.avaje/avaje-validator.svg?label=Maven%20Central)](https://maven-badges.herokuapp.com/maven-central/io.avaje/avaje-validator)
7+
[![javadoc](https://javadoc.io/badge2/io.avaje/avaje-config/javadoc.svg?color=purple)](https://javadoc.io/doc/io.avaje/avaje-config/latest/io.avaje.config/io/avaje/config/package-summary.html)
58
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/avaje/avaje-inject/blob/master/LICENSE)
6-
[![Discord](https://img.shields.io/discord/1074074312421683250?color=%237289da&label=discord)](https://discord.gg/Qcqf9R27BR)
7-
[![native image build](https://github.com/avaje/avaje-validator/actions/workflows/native-image.yml/badge.svg)](https://github.com/avaje/avaje-validator/actions/workflows/native-image.yml)
8-
99
Reflection-free pojo validation via apt source code generation. A light (~120kb + generated code) source code generation style alternative to Hibernate Validation. (code generation vs reflection)
1010

1111
- Annotate java classes with `@Valid` (or use `@ImportValidPojo` for types we "don't own" such as external dependencies)

validator-generator/src/main/java/io/avaje/validation/generator/ValidPrism.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
import javax.lang.model.element.AnnotationMirror;
44
import javax.lang.model.element.Element;
55

6+
import io.avaje.prism.GeneratePrism;
7+
8+
@GeneratePrism(
9+
value = javax.validation.Valid.class,
10+
name = "JavaxValidPrism",
11+
superInterfaces = ValidPrism.class)
12+
@GeneratePrism(
13+
value = jakarta.validation.Valid.class,
14+
name = "JakartaValidPrism",
15+
superInterfaces = ValidPrism.class)
16+
@GeneratePrism(
17+
value = io.avaje.validation.constraints.Valid.class,
18+
name = "AvajeValidPrism",
19+
superInterfaces = ValidPrism.class)
20+
@GeneratePrism(
21+
value = io.avaje.http.api.Valid.class,
22+
name = "HttpValidPrism",
23+
superInterfaces = ValidPrism.class)
624
public interface ValidPrism {
725

826
static boolean isPresent(Element e) {

validator-generator/src/main/java/io/avaje/validation/generator/package-info.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
1-
@GeneratePrism(
2-
value = io.avaje.validation.constraints.Valid.class,
3-
name = "AvajeValidPrism",
4-
superInterfaces = ValidPrism.class)
51
@GeneratePrism(io.avaje.validation.ImportValidPojo.class)
62
@GeneratePrism(io.avaje.validation.adapter.ConstraintAdapter.class)
7-
@GeneratePrism(
8-
value = javax.validation.Valid.class,
9-
name = "JavaxValidPrism",
10-
superInterfaces = ValidPrism.class)
11-
@GeneratePrism(
12-
value = jakarta.validation.Valid.class,
13-
name = "JakartaValidPrism",
14-
superInterfaces = ValidPrism.class)
15-
@GeneratePrism(
16-
value = io.avaje.http.api.Valid.class,
17-
name = "HttpValidPrism",
18-
superInterfaces = ValidPrism.class)
193
@GeneratePrism(io.avaje.validation.spi.MetaData.class)
204
@GeneratePrism(io.avaje.validation.spi.MetaData.Factory.class)
215
@GeneratePrism(io.avaje.validation.spi.MetaData.AnnotationFactory.class)

validator/src/main/java/io/avaje/validation/adapter/OptionalValidationAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public boolean validate(T value, ValidationRequest req, String propertyName) {
2020
if (value instanceof final Optional<?> o) {
2121
o.ifPresent(v -> initalAdapter.validate((T) v, req, propertyName));
2222
} else if (value instanceof final OptionalInt i) {
23-
i.ifPresent(v -> initalAdapter.validate((T) (Object) v, req, propertyName));
23+
i.ifPresent(v -> initalAdapter.validate((T) (Integer) v, req, propertyName));
2424
} else if (value instanceof final OptionalLong l) {
25-
l.ifPresent(v -> initalAdapter.validate((T) (Object) v, req, propertyName));
25+
l.ifPresent(v -> initalAdapter.validate((T) (Long) v, req, propertyName));
2626
} else if (value instanceof final OptionalDouble d) {
27-
d.ifPresent(v -> initalAdapter.validate((T) (Object) v, req, propertyName));
27+
d.ifPresent(v -> initalAdapter.validate((T) (Double) v, req, propertyName));
2828
}
2929
return true;
3030
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** classes and interfaces used for building generated/custom constraint adapters */
2+
package io.avaje.validation.adapter;

validator/src/main/java/io/avaje/validation/core/adapters/DomainNameUtil.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static java.util.regex.Pattern.CASE_INSENSITIVE;
44

55
import java.net.IDN;
6-
import java.util.regex.Matcher;
76
import java.util.regex.Pattern;
87

98
/**
@@ -86,11 +85,6 @@ private static boolean isValidDomainAddress(String domain, Pattern pattern) {
8685
return false;
8786
}
8887

89-
final Matcher matcher = pattern.matcher(domain);
90-
if (!matcher.matches()) {
91-
return false;
92-
}
93-
94-
return true;
88+
return pattern.matcher(domain).matches();
9589
}
9690
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Avaje Validation API - see {@link io.avaje.validation.Validator}.
3+
*
4+
* <h2>Example:</h2>
5+
*
6+
* <pre>{@code
7+
* // Annotate classes with @Valid
8+
*
9+
* @Valid
10+
* public class Address {
11+
*
12+
* // annotate fields with contraints
13+
* @NotBlank
14+
* private String street;
15+
*
16+
* @NotEmpty(message="must not be empty")
17+
* private List<@NotBlank String> owners; // message will be interpolated from bundle
18+
*
19+
* //getters/setters
20+
* }
21+
*
22+
* --------------------------------------------------
23+
*
24+
* final Validator validator = Validator.builder().build();
25+
*
26+
* Address address = ...;
27+
* validator.validate(address);
28+
*
29+
* }</pre>
30+
*/
31+
package io.avaje.validation;

validator/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** Avaje Validation Library */
12
module io.avaje.validation {
23
exports io.avaje.validation;
34
exports io.avaje.validation.adapter;

0 commit comments

Comments
 (0)