@Documented @Retention(RUNTIME) @Target(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 | Optional Element | Description |
---|---|---|
boolean |
allowEven |
The value is allowed to be even.
|
boolean |
allowInfinity |
|
boolean |
allowNaN |
|
boolean |
allowNegative |
|
boolean |
allowOdd |
The value is allowed to be odd.
|
boolean |
allowZero |
|
double[] |
divisibleBy |
|
double[] |
greaterThan |
Numeric lower bound (exclusive).
|
double[] |
lessThan |
Numeric upper bound (exclusive).
|
double[] |
max |
Numeric upper bound (inclusive).
|
double[] |
min |
Numeric lower bound (inclusive).
|
double[] |
multipleOf |
Number must be divisible by this.
|
Validate.OnFailure |
onFailure |
What to do when a raw value violates the validation rules.
|
String[] |
validCharacters |
|
String[] |
validPatterns |
Validate.OnFailure onFailure
Validate.OnFailure.THROW
, which throws an
IllegalArgumentException
.boolean allowEven
SingleInt
, SingleLong
, SingleDecimal
, SingleDouble
.String[] validCharacters
String[] validPatterns
Copyright © 2020. All rights reserved.