MapBuilder<T, K> class
Builder for map validations with map-specific methods.
Usage Examples:
// Simple schema validation
final userValidator = v().map().schema({
'name': v().string().lengthMin(1).build(),
'age': v().int_().gte(0).build(),
}).build();
// Strict validation (no extra fields allowed)
final strictUserValidator = v().map().strict({
'id': v().string().lengthMin(1).build(),
'email': v().string().email().build(),
}).build();
// Nested object validation
final addressValidator = v().map().schema({
'street': v().string().lengthMin(5).build(),
'city': v().string().lengthMin(2).build(),
'zipCode': v().string().matches(r'^\d{5}$').build(),
}).build();
- Inheritance
-
- Object
- IValidator
- BaseBuilder<
MapBuilder< T, K> , Map<T, K> > - MapBuilder
- Mixed-in types
-
- TransformerMixin<
MapBuilder< T, K> , Map<T, K> > - MapMixin<
MapBuilder< T, K> , Map<T, K> > - EmptyMixin<
MapBuilder< T, K> , Map<T, K> > - ComparisonMixin<
MapBuilder< T, K> , Map<T, K> >
- TransformerMixin<
- Available extensions
Constructors
- MapBuilder({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
→ MapBuilder<
T, K> -
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
→ MapBuilder<
T, K> -
no setterinherited
Methods
-
add(
IValidator validator, {String? message}) → MapBuilder< T, K> -
Add a validator to the chain.
inherited
-
build(
) → IValidator -
Build resulting validator.
inherited
-
containsKey(
dynamic key, {String? message}) → MapBuilder< T, K> -
Validate that the map contains the specified key.
inherited
-
copyWith(
{bool? nullable, bool? optional}) → IValidator -
inherited
-
deepEq(
Map< T, K> value, {String? message}) → MapBuilder<T, K> -
Require the value to be deeply equal to the specified value.
inherited
-
empty(
{String? message}) → MapBuilder< T, K> -
Validate that the value is empty.
inherited
-
eq(
Map< T, K> value, {String? message}) → MapBuilder<T, K> -
Require the value to be equal to the specified value.
inherited
-
error(
String message) → MapBuilder< T, K> -
Override final error message (retains codes).
inherited
-
flattenKeys(
[String delimiter = '.']) → MapBuilder< T, K> -
Flatten nested map keys using the specified delimiter.
inherited
-
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}) → MapBuilder< T, K> -
Mark current chain nullable (null accepted as valid).
inherited
-
oneOf(
Iterable< Map< values, {String? message}) → MapBuilder<T, K> >T, K> -
Require the value to be one of the specified options.
inherited
-
optional<
_> () → MapBuilder< T, K> -
Mark current chain optional (skipped when key absent).
inherited
-
pick(
Iterable< String> keys) → MapBuilder<T, K> -
Extract only the specified keys from the map.
inherited
-
pluck(
String key) → MapBuilder< T, K> -
Extract a single key from the map, keeping the map structure.
@return The builder for chaining
inherited
-
pluckValue(
String key) → GenericBuilder -
Extract a single value from the map, returning a GenericBuilder for further operations.
@return A GenericBuilder for the extracted value
inherited
-
schema(
Map< String, IValidator> schema) → MapBuilder<T, K> -
Validate the map against a schema where keys are optional unless specified.
inherited
-
strict(
Map< String, IValidator> schema) → MapBuilder<T, K> -
Validate the map against a strict schema where all keys must be present and match the validators.
inherited
-
toBigInt(
) → NumberBuilder -
Transform the value to a BigInt.
inherited
-
toBool(
{String? message}) → BoolBuilder -
Transform the value to a boolean using standard parsing.
inherited
-
toBoolLenient(
{String? message}) → BoolBuilder -
Transform the value to a boolean using lenient parsing.
inherited
-
toBoolStrict(
{String? message}) → BoolBuilder -
Transform the value to a boolean using strict parsing.
inherited
-
toDateTime(
) → DateTimeBuilder -
Transform string to DateTime using standard parsing.
inherited
-
toDouble(
{String? message}) → DoubleBuilder -
Transform the value to a double using standard parsing.
inherited
-
toInt(
{String? message}) → IntBuilder -
Transform the value to an integer using standard parsing.
inherited
-
toIntSafe(
{String? message}) → IntBuilder -
Transform the value to an integer using safe parsing (returns null on failure).
inherited
-
toIntStrict(
{String? message}) → IntBuilder -
Transform the value to an integer using strict parsing (no fallback to 0).
inherited
-
toJson(
) → JsonDecodedBuilder -
Transform JSON string to decoded object (Map/List).
inherited
-
toNum(
) → NumberBuilder -
Transform the value to a number (int or double).
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
toString_(
{String? message}) → StringBuilder -
Transform the value to a string.
inherited
-
use(
CustomPivot pivot) → GenericBuilder -
Apply a custom transformation using the provided pivot.
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}) → MapBuilder< T, K> -
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 theerror
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