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 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 an instance of a class.
the desired class
a validator for an object of the desired class
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 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
boolean
.