-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tested and reworked some validators (Max/MinLength are just usable fo…
…r Strings now)
- Loading branch information
1 parent
ecd471f
commit a88ba41
Showing
18 changed files
with
491 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 17 additions & 15 deletions
32
...pigen-validation-api/src/main/java/io/toolisticon/fluapigen/validation/api/MaxLength.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 12 additions & 11 deletions
23
fluapigen-validation-api/src/main/java/io/toolisticon/fluapigen/validation/api/NotEmpty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
fluapigen-validation-api/src/main/java/io/toolisticon/fluapigen/validation/api/NotNull.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
fluapigen-validation-api/src/main/java/io/toolisticon/fluapigen/validation/api/Nullable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.toolisticon.fluapigen.validation.api; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Needed to overrule {@link NotNull} annotations on method or enclosing interfaces/types. | ||
* All parameters are by default nullable. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE}) | ||
@FluentApiValidator(value = Nullable.ValidatorImpl.class, overwrites = NotNull.class) | ||
public @interface Nullable { | ||
|
||
class ValidatorImpl implements Validator<Object> { | ||
@Override | ||
public boolean validate(Object obj) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean validate(Object[] obj) { | ||
return true; | ||
} | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
fluapigen-validation-api/src/main/java/io/toolisticon/fluapigen/validation/api/OfLength.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.toolisticon.fluapigen.validation.api; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Checks if string has specific length. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.PARAMETER) | ||
@FluentApiValidator(value = OfLength.ValidatorImpl.class, attributeNamesToConstructorParameterMapping = {"value", "target"}) | ||
public @interface OfLength { | ||
|
||
int value(); | ||
|
||
class ValidatorImpl implements Validator<String> { | ||
|
||
private final int ofLength; | ||
|
||
|
||
public ValidatorImpl(int ofLength) { | ||
|
||
this.ofLength = ofLength; | ||
|
||
} | ||
|
||
@Override | ||
public boolean validate(String obj) { | ||
return obj == null || obj.length() == ofLength; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...en-validation-api/src/main/java/io/toolisticon/fluapigen/validation/api/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* This package contains all kind of predefined validators. | ||
* Some validators like {@link io.toolisticon.fluapigen.validation.api.Nullable} and {@link io.toolisticon.fluapigen.validation.api.NotNull} can also be used on method or type level to define a default behavior. | ||
*/ | ||
package io.toolisticon.fluapigen.validation.api; | ||
|
Oops, something went wrong.