BaseBuilder<B extends BaseBuilder<B, T>, T> class

Base functionality shared by all typed builders.

This class provides the core builder pattern functionality including:

  • Method chaining for fluent API
  • Negation support (using not)
  • Error message customization
  • Optional/nullable modifiers
  • Final validator building

Builder Pattern Usage:

// Basic chaining
final validator = v().string().lengthMin(5).email().build();

// Negation
final notEmpty = v().string().not().empty().build();

// Custom error messages
final customError = v().string().lengthMin(5).error("Name too short").build();

// Optional fields
final optionalField = v().string().optional().lengthMin(2).build();
Inheritance
Implementers
Available extensions

Constructors

BaseBuilder({bool negated = false, Chain? chain, bool? optional, bool? nullable})

Properties

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

Methods

add(IValidator validator, {String? message}) → B
Add a validator to the chain.
build() IValidator
Build resulting validator.
copyWith({bool? nullable, bool? optional}) IValidator
override
deepEq(T value, {String? message}) → B
Require the value to be deeply equal to the specified value.
eq(T value, {String? message}) → B
Require the value to be equal to the specified value.
error(String message) → B
Override final error message (retains codes).
isNotValid(dynamic value) bool
inherited
isNotValidAsync(dynamic value) FutureOr<bool>
inherited
isValid(dynamic value) bool
inherited
isValidAsync(dynamic value) FutureOr<bool>
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
nullable<_>({String? message}) → B
Mark current chain nullable (null accepted as valid).
override
oneOf(Iterable<T> values, {String? message}) → B
Require the value to be one of the specified options.
optional<_>() → B
Mark current chain optional (skipped when key absent).
override
toString() String
A string representation of this object.
inherited
validate(dynamic value, {bool? exists}) Result
Convenience validate (sync only chain).
override
validateAsync(dynamic value, {bool? exists}) Future<Result>
Convenience validateAsync (mixed / async).
override
validateOrThrow(dynamic value) Result
inherited
validator(dynamic value) FutureOr<Result>
override
wrap(IValidator fn(IValidator), {String? message}) → B
Wrap the current chain with a custom function.

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