EachKey class

An annotation that checks every key of a map against constraints.

Use it when the keys are user input, such as the names of a score table. A null map is skipped; a value that is not a map throws a ConstraintDeclarationException. A key is reported as scores<K>[key].<map key> (field error on scores[key]). Jakarta's container element constraint on a map key (Map<@NotBlank String, Integer>).

// Subject names of at most 10 characters.
@Introspected()
class Survey {
  @EachKey([Size(max: 10)])
  Map<String, int> scores = {};
}

Spring (Java):

private Map<@Size(max = 10) String, Integer> scores;

Constructors

EachKey(List<Constraint> constraints)
Checks constraints on every key of the map.
const

Properties

constraints → List<Constraint>
The constraints each key must meet.
final
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