Valid class
An annotation that asks for the constraints inside an object to be checked: of a nested object, of the objects in a list, set or map, or of a request body or method argument.
Constraints are not checked inside a property by default; @Valid()
says "go in here". In the web starter, @Valid() on a @RequestBody
parameter checks the body and answers a 400 when it is invalid. On a
parameter or method of a @Validated() bean it checks the argument or
the result.
Errors inside a list element are reported as items[0].sku, inside
another iterable (a set) as items[].sku, inside a map value as
byKey[key].sku. null values are skipped. An object reached on
several paths is checked on each, but one that contains itself is not
entered again. ConvertGroup changes the groups of the nested check.
Jakarta's @Valid.
// An order is only valid with a valid address and valid items.
@Introspected()
class Order {
@Valid()
Address address = Address();
@Valid()
List<Item> items = [];
}
Spring (Java):
class Order {
@Valid
private Address address;
@Valid
private List<Item> items;
}
Constructors
- Valid()
-
The
@Valid()annotation; it has no settings.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited