ListBuilder<T> class

Builder for list validations, inherits from IterableBuilder.

Usage Examples:

// Basic list validation
final listValidator = v().list().lengthMin(1).build();

// String list with constraints
final tagsValidator = v().list()
  .each(v().string().lengthMin(1).lengthMax(50).build())
  .lengthMax(10)
  .build();

// Number list validation
final scoresValidator = v().list()
  .each(v().number().gte(0).lte(100).build())
  .lengthMin(1)
  .build();
Inheritance
Available extensions

Constructors

ListBuilder({Chain? chain})

Properties

chain Chain
finalinherited
hashCode int
The hash code for this object.
no setterinherited
isNullable bool
finalinherited
isOptional bool
finalinherited
negated bool
getter/setter pairinherited
not IterableBuilder<T>
Return a negated version of the builder (the negation flag is consumed by the next added validator)
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
self IterableBuilder<T>
no setterinherited

Methods

add(IValidator validator, {String? message}) IterableBuilder<T>
Add a validator to the chain.
inherited
build() IValidator
Build resulting validator.
inherited
contains(dynamic value, {String? message}) IterableBuilder<T>
Validate that the value contains the specified element.
inherited
copyWith({bool? nullable, bool? optional}) IValidator
inherited
deepEq(Iterable<T> value, {String? message}) IterableBuilder<T>
Require the value to be deeply equal to the specified value.
inherited
each(IValidator elementValidator) IterableBuilder<T>
Validate that each element in the iterable satisfies the provided validator.
inherited
empty({String? message}) IterableBuilder<T>
Validate that the value is empty.
inherited
eq(Iterable<T> value, {String? message}) IterableBuilder<T>
Require the value to be equal to the specified value.
inherited
error(String message) IterableBuilder<T>
Override final error message (retains codes).
inherited
isNotValid(dynamic value) bool
inherited
isNotValidAsync(dynamic value) FutureOr<bool>
inherited
isValid(dynamic value) bool
inherited
isValidAsync(dynamic value) FutureOr<bool>
inherited
length(List<IValidator> lengthValidators, {String? message}) IterableBuilder<T>
Validate that the length matches all the provided validators.
inherited
lengthMax(int max, {String? message}) IterableBuilder<T>
Validate that the length is at most the specified maximum.
inherited
lengthMin(int min, {String? message}) IterableBuilder<T>
Validate that the length is at least the specified minimum.
inherited
lengthRange(int min, int max, {String? message}) IterableBuilder<T>
Validate that the length is within the specified range.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
nullable<_>({String? message}) IterableBuilder<T>
Mark current chain nullable (null accepted as valid).
inherited
oneOf(Iterable<Iterable<T>> values, {String? message}) IterableBuilder<T>
Require the value to be one of the specified options.
inherited
optional<_>() IterableBuilder<T>
Mark current chain optional (skipped when key absent).
inherited
toString() String
A string representation of this object.
inherited
validate(dynamic value, {bool? exists}) Result
Convenience validate (sync only chain).
inherited
validateAsync(dynamic value, {bool? exists}) Future<Result>
Convenience validateAsync (mixed / async).
inherited
validateOrThrow(dynamic value) Result
inherited
validator(dynamic value) FutureOr<Result>
inherited
wrap(IValidator fn(IValidator), {String? message}) IterableBuilder<T>
Wrap the current chain with a custom function.
inherited

Operators

operator &(IValidator other) IValidator

Available on IValidator, provided by the EskemaEskValidatorOperations extension

Combines two validators with a logical AND, same as using all
operator ==(Object other) bool
The equality operator.
inherited
operator >(Expectation error) IValidator

Available on IValidator, provided by the EskemaEskValidatorOperations extension

Returns a new validator that will return the error message if the validation fails
operator |(IValidator other) IValidator

Available on IValidator, provided by the EskemaEskValidatorOperations extension

Combines two validators with a logical OR, same as using any