Facilitates the validation of related properties. For example,
```ts requireThat(nameToFrequency, "nameToFrequency"). and(m => m.size().isPositive()). and(m => m.keySet().contains("John")); ```
Any changes made during the validation process will impact this validator.
the nested validation
this
Returns the array of failed validations.
an array of failed validations
Returns the contextual information for upcoming validations carried out by this validator. The contextual
information is a map of key-value pairs that can provide more details about validation failures. For
example, if the message is "Password may not be empty" and the map contains the key-value pair
{"username": "john.smith"}
, the error message would be:
Password may not be empty
username: john.smith
an unmodifiable map from each entry's name to its value
Returns the value that is being validated.
the fallback value to use if the value is invalid
the validated value, or defaultValue
if the value is invalid (e.g. due to dereferencing a
property of a null
value)
Ensures that the value is within a range.
the lower bound of the range (inclusive)
the upper bound of the range (exclusive)
this
Ensures that the value is within a range.
the lower bound of the range
true
if the lower bound of the range is inclusive
the upper bound of the range
true
if the upper bound of the range is inclusive
this
RangeError if minimum
is greater than maximum
. If
minimumInclusive
is true
, and the value is less than minimum
.
If minimumInclusive
is false
, and the value is less than or equal to
minimum
. If maximumInclusive
is true
and the value is greater
than maximum
. If maximumInclusive
is false
, and the value is
greater than or equal to maximum
.
Ensures that the value is equal to expected
.
the expected value
this
Ensures that the value is equal to expected
.
the expected value
the name of the expected value
this
Ensures that the value is greater than a lower bound.
the exclusive lower bound
this
Ensures that the value is greater than a lower bound.
the exclusive lower bound
the name of the lower bound
this
Ensures that the value is greater than or equal to a minimum value.
the minimum value
this
Ensures that the value is greater than or equal a minimum value.
the minimum value
the name of the minimum value
this
Ensures that the value is an instance of a class.
the desired class
a validator for an object of the desired class
Ensures that the value is less than an upper bound.
the exclusive upper bound
this
Ensures that the value is less than an upper bound.
the exclusive upper bound
the name of the upper bound
this
Ensures that the value is less than or equal to a maximum value.
the inclusive upper value
this
Ensures that the value is less than or equal to a maximum value.
the maximum value
the name of the maximum value
this
Ensures that the value is a multiple of factor
.
the number being multiplied
this
Ensures that the value is a multiple of factor
.
the number being multiplied
the name of the factor
this
Ensures that the value is not equal to unwanted
.
the unwanted value
this
Ensures that the value is not equal to unwanted
.
the unwanted value
the name of the other value
this
Ensures that the value is not an instance of a class.
the unwanted class
this
Ensures that the value is not a multiple of factor
.
the number being multiplied
this
Ensures that the value is not a multiple of factor
.
the number being multiplied
the name of the factor
this
Ensures that the value is not null
.
This method should be used to validate method arguments that are assigned to class fields but not accessed right away (such as constructor and setter arguments). It should also be used to validate any method arguments when the validator contains additional contextual information.
this
Ensures that the value is not undefined.
This method should be used to validate method arguments that are assigned to class fields but not accessed right away (such as constructor and setter arguments). It should also be used to validate any method arguments when the validator contains additional contextual information.
this
Ensures that the value is null
.
this
Ensures that the value is undefined.
this
Sets the contextual information for upcoming validations.
This method adds contextual information to error messages. The contextual information is stored as key-value pairs in a map. Values set by this method override any values that are set using Validators.withContext.
There is no way to remove contextual information from a validator. Thread-level contextual information is removed automatically.
the value of the entry
the name of an entry
this
Validates the state of a
number
.