@Documented @Retention(value=RUNTIME) @Target(value=TYPE) public @interface Validate
SingleString
, SingleInt
, SingleLong
, SingleDecimal
, or
SingleDouble
subclasses, to ensure their values are always valid. Doing so tends to push data validation
out to the edges of an application, where it receives input from the outside world, freeing the internal logic from
the need to think about the possibility of invalid values.Modifier and Type | Fields and Description |
---|---|
static String |
DIGITS
Digit characters.
|
static String |
LETTERS
Letters (of the English alphabet).
|
Modifier and Type | Optional Element and Description |
---|---|
boolean |
allowInfinity
Set true to allow infinite floating-point values.
|
boolean |
allowNaN
Set true to allow not-a-number floating-point values.
|
String[] |
chars
Strings containing all allowed characters.
|
double[] |
greaterThan
Lower bound (exclusive) for numeric values, or the length of strings.
|
double[] |
lessThan
Numeric upper bound (exclusive) for numeric values, or the length of strings.
|
String[] |
match
Allowed regex patterns for string values.
|
double[] |
max
Upper bound (inclusive) for numeric values, or the length of strings.
|
double[] |
min
Lower bound (inclusive) for numeric values, or the length of strings.
|
double[] |
multipleOf
Number must be divisible by this.
|
String[] |
notChars
Strings containing all disallowed characters.
|
String[] |
notMatch
Disallowed regex patterns for string values.
|
ValidationPolicy |
onFailure
What to do when a raw value violates the validation rules.
|
public static final String LETTERS
public static final String DIGITS
public abstract ValidationPolicy onFailure
ValidationPolicy.THROW
, which throws an IllegalArgumentException
.public abstract double[] min
public abstract double[] max
public abstract double[] greaterThan
public abstract double[] lessThan
public abstract double[] multipleOf
public abstract boolean allowInfinity
public abstract boolean allowNaN
public abstract String[] chars
public abstract String[] notChars
public abstract String[] match
public abstract String[] notMatch
Copyright © 2022. All rights reserved.