Skip to content
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

Param Validation Aspect #65

Merged
merged 42 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
00b3960
Merge branch 'type-use2' into composite
SentryMan Jul 1, 2023
03802de
start
SentryMan Jul 1, 2023
6fabaf9
working
SentryMan Jul 2, 2023
f9f5fc7
Delete CombinationConstraint.java
SentryMan Jul 2, 2023
4137b86
fix indents
SentryMan Jul 2, 2023
de81a5b
fix combining
SentryMan Jul 2, 2023
2c28d66
Update ContactValidationAdapter.java
SentryMan Jul 2, 2023
61912d0
rename
SentryMan Jul 2, 2023
7b316c2
javax/jakarta
SentryMan Jul 2, 2023
7cb3e0c
annotation type
SentryMan Jul 2, 2023
6c5dd05
Update SimpleAdapterWriter.java
SentryMan Jul 2, 2023
a1dd515
Merge remote-tracking branch 'upstream/main' into composite
SentryMan Jul 2, 2023
ca72524
tests
SentryMan Jul 2, 2023
473709f
move contraint
SentryMan Jul 2, 2023
a5b67e6
fix test
SentryMan Jul 2, 2023
3fce154
Update ContraintReader.java
SentryMan Jul 2, 2023
0dd1975
parameter
SentryMan Jul 2, 2023
22c038c
method validatio0n
SentryMan Jul 4, 2023
94ab18f
filter blank
SentryMan Jul 4, 2023
e80bcf6
fix module
SentryMan Jul 4, 2023
c77c9f6
Update build.yml
SentryMan Jul 4, 2023
4b757d3
Update build.yml
SentryMan Jul 4, 2023
35a34da
corretto?
SentryMan Jul 4, 2023
facc417
syso time
SentryMan Jul 4, 2023
8a038b0
Update build.yml
SentryMan Jul 4, 2023
2254d55
more syso
SentryMan Jul 4, 2023
b20c39e
check all rounds
SentryMan Jul 5, 2023
885ed7b
Update ValidationProcessor.java
SentryMan Jul 5, 2023
bf9ef0e
wait I think I know
SentryMan Jul 5, 2023
2645907
we need the new inject
SentryMan Jul 5, 2023
3d1a68f
proper plugin
SentryMan Jul 5, 2023
18be90d
fix formatting
SentryMan Jul 5, 2023
0389720
validate method is a bean
SentryMan Jul 5, 2023
311e0d9
validate method is a bean
SentryMan Jul 5, 2023
d005f7d
Merge branch 'param' of https://github.com/SentryMan/avaje-validator …
SentryMan Jul 5, 2023
b07e23b
Update Append.java
SentryMan Jul 5, 2023
8abfaeb
locale for method param
SentryMan Jul 5, 2023
72adf8f
Update ValidateParams.java
SentryMan Jul 5, 2023
44cdd6e
more effecient
SentryMan Jul 5, 2023
314d312
temporal tolerance properties
SentryMan Jul 5, 2023
70f3795
Update DefaultValidatorProvider.java
SentryMan Jul 5, 2023
8207084
DRYing off a bit
SentryMan Jul 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: [17]
java_version: [17,20]
os: [ubuntu-latest]

steps:
Expand Down
180 changes: 107 additions & 73 deletions blackbox-test/pom.xml
Original file line number Diff line number Diff line change
@@ -1,76 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-validator-parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>

<artifactId>validator-blackbox-test</artifactId>
<name>validator blackbox test</name>
<description>test module</description>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<java.release>17</java.release>
</properties>

<dependencies>

<!-- for testing fields with third party annotations -->
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.2</version>
</dependency>

<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.0.Final</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-validator</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-validator-generator</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->

<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>

</dependencies>


<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-validator-parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>

<artifactId>validator-blackbox-test</artifactId>
<name>validator blackbox test</name>
<description>test module</description>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<java.release>17</java.release>
<inject.version>9.3-RC3</inject.version>
</properties>

<dependencies>

<!-- for testing fields with third party annotations -->
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.2</version>
</dependency>

<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.0.Final</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-validator</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>validator-constraints</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-validator-inject-plugin</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-validator-generator</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject</artifactId>
<version>${inject.version}</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject-generator</artifactId>
<version>${inject.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject-test</artifactId>
<version>${inject.version}</version>
<scope>test</scope>
</dependency>
<!-- test dependencies -->

<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>

</dependencies>


<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package example.avaje.composable;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.SOURCE;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import io.avaje.validation.constraints.Constraint;
import io.avaje.validation.constraints.Digits;
import io.avaje.validation.constraints.Negative;
import io.avaje.validation.constraints.Positive;

@Digits(integer = 2)
@Constraint
@Retention(SOURCE)
@Target(TYPE)
public @interface DigitsContraint {

String message() default "";

Class<?>[] groups() default {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package example.avaje.composable;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.SOURCE;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import io.avaje.validation.constraints.Constraint;
import io.avaje.validation.constraints.Positive;

@Positive
@Constraint
@Target(TYPE)
@Retention(SOURCE)
@DigitsContraint
public @interface PositiveContraint {

String message() default "";

Class<?>[] groups() default {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package example.avaje.composable;

import jakarta.validation.Valid;

@Valid
public record Sans(
@SansPositiveContraint(message = "must have positive double digit amount of puns") int puns) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package example.avaje.composable;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.SOURCE;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import jakarta.validation.Constraint;

@Retention(SOURCE)
@Target(FIELD)
@Constraint(validatedBy = {})
@PositiveContraint(message = "ignored message")
public @interface SansPositiveContraint {

String message();

Class<?>[] groups() default {};
}
16 changes: 16 additions & 0 deletions blackbox-test/src/main/java/example/avaje/method/MethodTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package example.avaje.method;

import java.util.List;

import io.avaje.validation.inject.aspect.ValidateParams;
import jakarta.inject.Singleton;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;

@Singleton
public class MethodTest {

@ValidateParams
void test(@NotEmpty List<@NotNull String> str, @Positive int inty, String regular) {}
}
6 changes: 3 additions & 3 deletions blackbox-test/src/main/java/example/avaje/typeuse/Ship.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import java.util.List;
import java.util.Map;

import io.avaje.validation.ValidPojo;
import io.avaje.validation.Valid;
import io.avaje.validation.constraints.NotBlank;
import io.avaje.validation.constraints.NotNull;

@ValidPojo
@Valid
public record Ship(
Map<
@NotNull(message = "Names cannot be null") @NotBlank(message = "Names cannot be blank")
String,
@NotNull(message = "Values cannot be null") @ValidPojo CrewMate>
@NotNull(message = "Values cannot be null") @Valid CrewMate>
crew,
List<
@NotNull(message = "Tasks cannot be null") @NotBlank(message = "Tasks cannot be blank")
Expand Down
4 changes: 2 additions & 2 deletions blackbox-test/src/test/java/example/avaje/AMyEmail.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package example.avaje;

import io.avaje.validation.ValidPojo;
import io.avaje.validation.Valid;
import io.avaje.validation.constraints.Email;

@ValidPojo
@Valid
public class AMyEmail {

@Email
Expand Down
4 changes: 2 additions & 2 deletions blackbox-test/src/test/java/example/avaje/AMyNumbers.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package example.avaje;

import io.avaje.validation.ValidPojo;
import io.avaje.validation.Valid;
import io.avaje.validation.constraints.DecimalMax;

import java.math.BigDecimal;

@ValidPojo
@Valid
public class AMyNumbers {

@DecimalMax("10.50")
Expand Down
4 changes: 2 additions & 2 deletions blackbox-test/src/test/java/example/avaje/AMyPattern.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package example.avaje;

import io.avaje.validation.ValidPojo;
import io.avaje.validation.Valid;
import io.avaje.validation.constraints.Pattern;

@ValidPojo
@Valid
public class AMyPattern {

@Pattern(regexp = "[0-3]+")
Expand Down
4 changes: 2 additions & 2 deletions blackbox-test/src/test/java/example/avaje/ANums.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package example.avaje;

import io.avaje.validation.ValidPojo;
import io.avaje.validation.Valid;
import io.avaje.validation.constraints.*;

import java.math.BigDecimal;

@ValidPojo
@Valid
public class ANums {

@Digits(integer = 5, fraction = 3)
Expand Down
4 changes: 2 additions & 2 deletions blackbox-test/src/test/java/example/avaje/APastFuture.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package example.avaje;

import io.avaje.validation.ValidPojo;
import io.avaje.validation.Valid;
import io.avaje.validation.constraints.*;

import java.time.LocalDate;

@ValidPojo
@Valid
public class APastFuture {

@Past
Expand Down
Loading