diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/AssertFalse.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/AssertFalse.java index e9d69ef1..c25b778a 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/AssertFalse.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/AssertFalse.java @@ -11,9 +11,10 @@ import java.lang.annotation.Target; /** - * The annotated element must be false. Supported types are {@code boolean} and {@code Boolean}. - * - *
{@code null} elements are considered valid. + * The annotated element must be false. + * Supported types are {@code boolean} and {@code Boolean}. + *
+ * {@code null} elements are considered valid. * * @author Emmanuel Bernard */ diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/AssertTrue.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/AssertTrue.java index 00cfd150..95a89b81 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/AssertTrue.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/AssertTrue.java @@ -11,9 +11,10 @@ import java.lang.annotation.Target; /** - * The annotated element must be true. Supported types are {@code boolean} and {@code Boolean}. - * - *
{@code null} elements are considered valid. + * The annotated element must be true. + * Supported types are {@code boolean} and {@code Boolean}. + *
+ * {@code null} elements are considered valid. * * @author Emmanuel Bernard */ diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/Constraint.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/Constraint.java index f7c518d7..a3e6a14b 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/Constraint.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/Constraint.java @@ -7,7 +7,8 @@ import java.lang.annotation.Target; /** - * Marks an annotation as a Constraint class. Only annotations marked with Constraint are composable + * Marks an annotation as a constraint class. + * Only annotations marked with {@code @Constraint} are composable. */ @Retention(CLASS) @Target({ANNOTATION_TYPE}) diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/DecimalMax.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/DecimalMax.java index 1abad855..5f034c18 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/DecimalMax.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/DecimalMax.java @@ -14,20 +14,18 @@ /** * The annotated element must be a number whose value must be lower or equal to the specified * maximum. - * - *
Supported types are: - * + *
+ * Supported types are: *
{@code null} elements are considered valid. + *
+ * {@code null} elements are considered valid. * * @author Emmanuel Bernard */ @@ -52,8 +50,8 @@ /** * Specifies whether the specified maximum is inclusive or exclusive. By default, it is inclusive. * - * @return {@code true} if the value must be lower or equal to the specified maximum, {@code - * false} if the value must be lower + * @return {@code true} if the value must be lower or equal to the specified maximum, + * {@code false} if the value must be lower * @since 1.1 */ boolean inclusive() default true; diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/DecimalMin.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/DecimalMin.java index 75e41f2d..0627484c 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/DecimalMin.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/DecimalMin.java @@ -20,20 +20,18 @@ /** * The annotated element must be a number whose value must be higher or equal to the specified * minimum. - * - *
Supported types are: - * + *
+ * Supported types are: *
{@code null} elements are considered valid. + *
+ * {@code null} elements are considered valid. * * @author Emmanuel Bernard */ @@ -58,8 +56,8 @@ /** * Specifies whether the specified maximum is inclusive or exclusive. By default, it is inclusive. * - * @return {@code true} if the value must be lower or equal to the specified maximum, {@code - * false} if the value must be lower + * @return {@code true} if the value must be lower or equal to the specified maximum, + * {@code false} if the value must be lower * @since 1.1 */ boolean inclusive() default true; diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/Digits.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/Digits.java index fe9d77ec..26544636 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/Digits.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/Digits.java @@ -15,17 +15,16 @@ /** * The annotated element must be a number within accepted range. - * - *
Supported types are: - * + *
+ * Supported types are: *
{@code null} elements are considered valid. + *
+ * {@code null} elements are considered valid. * * @author Emmanuel Bernard */ @@ -38,14 +37,21 @@ Class>[] groups() default {}; + /** Return maximum number of integral digits accepted for this number */ int integer(); + /** Return maximum number of fractional digits accepted for this number */ int fraction() default 0; + /** + * Defines several {@link Digits} annotations on the same element. + * + * @see Digits + */ @Target({ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented - public @interface Digitses { + @interface Digitses { Digits[] value(); } } diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/Email.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/Email.java index 931ee6a3..4b7ead39 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/Email.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/Email.java @@ -13,10 +13,10 @@ /** * The string has to be a well-formed email address. Exact semantics of what makes up a valid email - * address are left to the provided Email Annotation ValidationAdapter providers. Accepts {@code - * CharSequence}. - * - *
{@code null} elements are considered valid. + * address are left to the provided Email Annotation ValidationAdapter providers. + *
+ * Accepts {@code CharSequence}. + * {@code null} elements are considered valid. */ @Constraint @Documented diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/Future.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/Future.java index 414cf7be..f097ad62 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/Future.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/Future.java @@ -13,13 +13,12 @@ /** * The annotated element must be an instant, date or time in the future. - * - *
Now is defined by the {@link Clock} Supplier attached to the {@link Validator}. The + *
+ * Now is defined by the {@code Clock} Supplier attached to the {@code Validator}. The * default clock defines the current time according to the virtual machine, applying the current * default time zone if needed. - * - *
Supported types are: - * + *
+ * Supported types are: *
{@code null} elements are considered valid. + *
+ * {@code null} elements are considered valid. */ @Constraint @Documented diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/FutureOrPresent.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/FutureOrPresent.java index 1072b137..d78b4e37 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/FutureOrPresent.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/FutureOrPresent.java @@ -13,16 +13,15 @@ /** * The annotated element must be an instant, date or time in the present or in the future. - * - *
Now is defined by the {@link Clock} Supplier attached to the {@link Validator}. The + *
+ * Now is defined by the {@code Clock} Supplier attached to the {@code Validator}. The * default clock defines the current time according to the virtual machine, applying the current * default time zone if needed. - * - *
The notion of present here is defined relatively to the type on which the constraint is used. - * For instance, if the constraint is on a {@link Year}, present would mean the whole current year. - * - *
Supported types are: - * + *
+ * The notion of present here is defined relatively to the type on which the constraint is used. + * For instance, if the constraint is on a {@code Year}, present would mean the whole current year. + *
+ * Supported types are: *
{@code null} elements are considered valid. + *
+ * {@code null} elements are considered valid. */ @Constraint @Documented diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/Length.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/Length.java index cbb3aa31..66487f85 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/Length.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/Length.java @@ -6,8 +6,8 @@ /** * The annotated string length must be between the specified boundaries (included). - * - *
Supported types are: + *
+ * Supported types are: *
Supported types are: - * + * The annotated element must be a number whose value must be lower or + * equal to the specified maximum. + *
+ * Supported types are: *
{@code null} elements are considered valid. + * Note that {@code double} and {@code float} are not supported due to rounding errors + * (some providers might provide some approximative support). + *
+ * {@code null} elements are considered valid. * * @author Emmanuel Bernard */ @@ -41,8 +40,14 @@ Class>[] groups() default {}; + /** Return value the element must be lower or equal to */ long value(); + /** + * Defines several {@link Max} annotations on the same element. + * + * @see Max + */ @Target({ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/Min.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/Min.java index f53060a5..080d97fd 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/Min.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/Min.java @@ -14,21 +14,20 @@ import java.lang.annotation.Target; /** - * The annotated element must be a number whose value must be higher or equal to the specified - * minimum. - * - *
Supported types are: - * + * The annotated element must be a number whose value must be higher or + * equal to the specified minimum. + *
+ * Supported types are: *
{@code null} elements are considered valid. + * Note that {@code double} and {@code float} are not supported due to rounding errors + * (some providers might provide some approximative support). + *
+ * {@code null} elements are considered valid. * * @author Emmanuel Bernard */ @@ -41,8 +40,14 @@ Class>[] groups() default {}; + /** Return value the element must be higher or equal to */ long value(); + /** + * Defines several {@link Min} annotations on the same element. + * + * @see Min + */ @Target({ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/Negative.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/Negative.java index f1d3e027..95bedb37 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/Negative.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/Negative.java @@ -12,19 +12,18 @@ import java.lang.annotation.Target; /** - * The annotated element must be a strictly negative number (i.e. 0 is considered as an invalid - * value). - * - *
Supported types are: - * + * The annotated element must be a strictly negative number (i.e. 0 is considered as an + * invalid value). + *
+ * Supported types are: *
{@code null} elements are considered valid. + *
+ * {@code null} elements are considered valid. * * @author Gunnar Morling */ diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/NegativeOrZero.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/NegativeOrZero.java index ff521b10..b66e4b1e 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/NegativeOrZero.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/NegativeOrZero.java @@ -13,17 +13,16 @@ /** * The annotated element must be a negative number or 0. - * - *
Supported types are: - * + *
+ * Supported types are: *
{@code null} elements are considered valid. + *
+ * {@code null} elements are considered valid. * * @author Gunnar Morling */ diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/NotBlank.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/NotBlank.java index 910bc839..12da9b0b 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/NotBlank.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/NotBlank.java @@ -12,8 +12,8 @@ import java.lang.annotation.Target; /** - * The annotated element must not be {@code null} and must contain at least one non-whitespace - * character. Accepts {@code CharSequence}. + * The annotated element must not be {@code null} and must contain at least one + * non-whitespace character. Accepts {@code CharSequence}. * * @author Hardy Ferentschik * @see Character#isWhitespace(char) @@ -24,7 +24,10 @@ @Retention(RUNTIME) public @interface NotBlank { - /** Set the maximum length. By default this is 0 meaning unlimited. */ + /** + * Set the maximum length. By default, this is 0 (meaning unlimited). + * This mimics the functionality of {@link Size} & {@link Length}, for a verbosity reduction. + */ int max() default 0; String message() default "{avaje.NotBlank.message}"; diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/NotEmpty.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/NotEmpty.java index 50558dd2..fe5778ec 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/NotEmpty.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/NotEmpty.java @@ -12,11 +12,17 @@ import java.lang.annotation.Target; /** - * The annotated element must not be {@code null} and must contain at least one non-whitespace - * character. Accepts {@code CharSequence}. + * The annotated element must not be {@code null} nor empty. + *
+ * Supported types are: + *
Now is defined by the {@link Clock} Supplier attached to the {@link Validator}. The + *
Now is defined by the {@code Clock} Supplier attached to the {@code Validator}. The * default clock defines the current time according to the virtual machine, applying the current * default time zone if needed. * diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/PastOrPresent.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/PastOrPresent.java index 796c6830..fa3e549e 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/PastOrPresent.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/PastOrPresent.java @@ -1,27 +1,21 @@ package io.avaje.validation.constraints; -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE_USE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import java.time.Clock; -import java.time.Year; + +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.*; /** * The annotated element must be an instant, date or time in the past or in the present. * - *
Now is defined by the {@link Clock} Supplier attached to the {@link Validator}. The + *
Now is defined by the {@code Clock} Supplier attached to the {@code Validator}. The * default clock defines the current time according to the virtual machine, applying the current * default time zone if needed. * *
The notion of present is defined relatively to the type on which the constraint is used. For - * instance, if the constraint is on a {@link Year}, present would mean the whole current year. + * instance, if the constraint is on a {@code Year}, present would mean the whole current year. * *
Supported types are: * diff --git a/validator-constraints/src/main/java/io/avaje/validation/constraints/RegexFlag.java b/validator-constraints/src/main/java/io/avaje/validation/constraints/RegexFlag.java index 67c35cc2..63850dd3 100644 --- a/validator-constraints/src/main/java/io/avaje/validation/constraints/RegexFlag.java +++ b/validator-constraints/src/main/java/io/avaje/validation/constraints/RegexFlag.java @@ -1,4 +1,5 @@ package io.avaje.validation.constraints; + /** Possible Regexp flags. */ public enum RegexFlag { @@ -58,7 +59,7 @@ public enum RegexFlag { this.value = value; } - /** @return flag value as defined in {@link java.util.regex.Pattern} */ + /** Return flag value as defined in {@link java.util.regex.Pattern} */ public int getValue() { return value; }