ArraySchema<T> class

Schema for validating array values with element validation

Inheritance

Constructors

ArraySchema(Schema<T> _elementSchema, {String? description, Map<String, dynamic>? metadata, int? minLength, int? maxLength, int? exactLength, bool nonempty = false})
const

Properties

description String?
Optional description for documentation purposes
finalinherited
elementSchema Schema<T>
Gets the element schema for this array
no setter
exactItems int?
no setter
hashCode int
The hash code for this object.
no setteroverride
maxItems int?
no setter
metadata Map<String, dynamic>?
Optional metadata for the schema
finalinherited
minItems int?
Public getters for JSON schema generation
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schemaType String
Gets a string representation of the schema type
no setterinherited
type Type
Gets the type that this schema validates to
no setterinherited
uniqueItems bool?
no setter

Methods

brand<B>() BrandedSchema<List<T>, B>
Creates a branded schema for nominal typing
inherited
defaultTo(List<T> defaultValue) Schema<List<T>>
Creates a new schema that provides a default value
inherited
defaultToComputed(List<T> defaultValue()) Schema<List<T>>
Creates a new schema that provides a computed default value
inherited
describe(String description, {Map<String, dynamic>? metadata}) Schema<List<T>>
Creates a new schema with a description and optional metadata
inherited
element(Schema<T> elementSchema) ArraySchema<T>
Creates a typed array schema with element refinement
every(bool predicate(T element), {String? message}) Schema<List<T>>
Validates that all array elements match a condition
excludes(T element) Schema<List<T>>
Checks if array excludes a specific element
fallback(List<T> fallbackValue) Schema<List<T>>
Creates a new schema that provides a fallback value
inherited
fallbackComputed(List<T> fallback(ValidationErrorCollection errors)) Schema<List<T>>
Creates a new schema that provides a computed fallback value
inherited
filter(bool predicate(T element)) Schema<List<T>>
Filters the array after validation
includes(T element) Schema<List<T>>
Checks if array includes a specific element
isValid(dynamic input, [List<String> path = const []]) bool
Validates the input and returns true if valid, false otherwise
inherited
length(int length) ArraySchema<T>
Sets exact length constraint
mapElements<R>(R mapper(T element)) Schema<List<R>>
Transforms the array after validation
max(int length) ArraySchema<T>
Sets maximum length constraint
min(int length) ArraySchema<T>
Sets minimum length constraint
nonempty() ArraySchema<T>
Ensures array is non-empty
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
nullable() Schema<List<T>?>
Creates a new schema that is nullable
inherited
optional() Schema<List<T>?>
Creates a new schema that is optional (nullable)
inherited
parse(dynamic input, [List<String> path = const []]) List<T>
Parses the input, throwing an exception if validation fails
inherited
parseAsync(dynamic input, [List<String> path = const []]) Future<List<T>>
Asynchronously parses the input, throwing an exception if validation fails
inherited
postprocess(List<T> postprocessor(List<T> value)) Schema<List<T>>
Creates a new schema that postprocesses the output
inherited
preprocess<R>(R preprocessor(dynamic input)) Schema<List<T>>
Creates a new schema that preprocesses the input
inherited
range(int min, int max) ArraySchema<T>
Ensures array has elements within the specified range
readonly() ReadonlySchema<List<T>>
Creates a readonly version of this schema
inherited
refine(bool validator(List<T> value), {String? message, String? code}) Schema<List<T>>
Creates a new schema that applies additional validation
inherited
refineAsync(Future<bool> validator(List<T> value), {String? message, String? code}) Schema<List<T>>
Creates a new schema that applies async validation
inherited
safeParse(dynamic input, [List<String> path = const []]) List<T>?
Safely parses the input, returning null if validation fails
inherited
safeParseAsync(dynamic input, [List<String> path = const []]) Future<List<T>?>
Asynchronously and safely parses the input, returning null if validation fails
inherited
some(bool predicate(T element), {String? message}) Schema<List<T>>
Validates that array has at least one element matching a condition
sort([int compare(T a, T b)?]) Schema<List<T>>
Sorts the array after validation
toString() String
A string representation of this object.
override
transform<R>(R transformer(List<T> value)) Schema<R>
Creates a new schema that applies a transformation after validation
inherited
transformAsync<R>(Future<R> transformer(List<T> value)) Schema<R>
Creates a new schema that applies an async transformation after validation
inherited
unique() Schema<List<T>>
Ensures array contains only unique elements
validate(dynamic input, [List<String> path = const []]) ValidationResult<List<T>>
Validates the input and returns a ValidationResult
override
validateAsync(dynamic input, [List<String> path = const []]) Future<ValidationResult<List<T>>>
Asynchronously validates the input and returns a ValidationResult
override

Operators

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