ContainsArrayValidator<T> class

A validator that checks if a list contains all required elements.

The ContainsArrayValidator ensures that a given list includes a predefined set of elements.

Example

final validator = ContainsArrayValidator(
  requiredElements: [1, 2, 3],
  message: 'The list must contain all required elements',
);

print(validator.validate([1, 2, 3, 4, 5])); // null (valid)
print(validator.validate([1, 2])); // 'The list must contain all required elements' (invalid)
print(validator.validate(['a', 'b', 'c'])); // 'The list must contain all required elements' (invalid)

Parameters

Behavior:

  • If the list contains all required elements, validation passes.
  • If any required element is missing, validation fails.
Inheritance

Constructors

ContainsArrayValidator.new({required List<T> requiredElements, required String message})
Creates a ContainsArrayValidator with a required elements list and a custom error message.

Properties

hashCode int
The hash code for this object.
no setterinherited
message String
The error message to be returned when validation fails.
finalinherited
requiredElements List<T>
The required elements that must be present in the list.
final
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
validate(covariant List<T> value) String?
Validates the provided value.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited