the type of the value
the type of elements in the collection
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
Ensures that the collection contains an element.
the element
this
Ensures that the collection contains an element.
the element
the name of the element
this
Ensures that the collection contains all the elements in expected
.
this
Ensures that the collection contains all the elements in expected
.
the desired elements
this
Ensures that the collection contains all the elements in expected
.
this
Ensures that the collection contains all the elements in expected
.
the desired elements
the name of the expected collection
this
Ensures that the collection contains any elements in expected
.
this
Ensures that the collection contains any elements in expected
.
the desired elements
this
Ensures that the collection contains at least one element in expected
.
this
Ensures that the collection contains at least one element in expected
.
the desired elements
the name of the expected collection
this
Ensures that the collection consists of the same elements as expected
, irrespective of their
order.
In contrast, isEqualTo() requires the same element ordering.
this
Ensures that the collection consists of the same elements as expected
, irrespective of
their order.
In contrast, isEqualTo() requires the same element ordering.
the desired elements
this
Ensures that the collection consists of the same elements as expected
, irrespective of their
order.
In contrast, isEqualTo() requires the same element ordering.
this
Ensures that the collection consists of the same elements as expected
, irrespective of
their order.
In contrast, isEqualTo() requires the same element ordering.
the desired elements
the name of the expected collection
this
Ensures that the collection does not contain unwanted
.
the unwanted element
this
Ensures that the collection does not contain unwanted
.
the unwanted element
the name of the element
this
Allows the collection to contain some, but not all, elements from a collection.
this
Allows the collection to contain some, but not all, elements from a collection.
the unwanted elements
this
Allows the collection to contain some, but not all, elements from a collection.
this
Allows the collection to contain some, but not all, elements from a collection.
the unwanted elements
the name of the unwanted collection
this
Ensures that the collection does not contain any of the elements in unwanted
.
this
Ensures that the collection does not contain any of the elements in unwanted
.
the unwanted elements
this
Ensures that the collection does not contain any of the elements in unwanted
.
this
Ensures that the collection does not contain any of the elements in unwanted
.
the unwanted elements
the name of the unwanted collection
this
Ensures that the collection and unwanted
consist of different elements, irrespective of their
order.
this
Ensures that the collection and unwanted
consist of different elements, irrespective of their
order.
the unwanted elements
this
Ensures that the collection and unwanted
consist of different elements, irrespective of
their order.
this
Ensures that the collection and unwanted
consist of different elements, irrespective of their
order.
the unwanted elements
the name of the unwanted collection
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 array is sorted.
a function that returns a negative number if first
should come
before second
, zero or NaN
if the two values are equal, or a positive number
if first
should come after second
.
this
Ensures that the value is undefined.
this
Returns a validator for the array's length.
a validator for the array's length
Returns a validator for the collection's size.
a validator for the collection's size
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 an array.