LazySchema<Boundary extends Object, Runtime extends Object> class
final
Defers resolving another schema until parse, validation, encode, or export time.
This enables recursive schema graphs where a child schema needs to refer back to an outer schema that is assigned after construction.
- Inheritance
- Mixed-in types
-
- FluentSchema<
Boundary, Runtime, LazySchema< Boundary, Runtime> >
- FluentSchema<
- Available extensions
- Annotations
-
- @immutable
Constructors
-
LazySchema(String name, AckSchema<
Boundary, Runtime> _builder(), {int maxDepth = defaultMaxDepth, bool isNullable = false, bool isOptional = false, String? description, List<Constraint< constraints = const [], List<Runtime> >Refinement< refinements = const []})Runtime> >
Properties
- acceptsNull → bool
-
Whether
parse(null)andencode(null)should accept null without raising a non-nullable failure. Defaults to isNullable; subclasses with branch-level null policies (e.g. AnyOfSchema) override this hook.no setterinherited - baseFieldsHashCode → int
-
Computes hash code for base schema fields.
no setterinherited
-
constraints
→ List<
Constraint< Runtime> > -
Returns an unmodifiable view of the constraints for this schema.
no setterinherited
- description → String?
-
finalinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- isNullable → bool
-
finalinherited
- isOptional → bool
-
finalinherited
- maxDepth → int
-
Maximum number of times this lazy schema may appear in its active context
chain before parsing, runtime validation, or encoding fails.
final
- name → String
-
Human-readable name for this deferred schema reference.
final
-
refinements
→ List<
Refinement< Runtime> > -
Returns an unmodifiable view of the refinements for this schema.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schemaType → SchemaType
-
The schema type category for this schema.
no setteroverride
- schemaTypeName → String
-
Human-readable type name for error messages and debugging.
no setterinherited
Methods
-
applyConstraintsAndRefinements(
Runtime value, SchemaContext context) → SchemaResult< Runtime> -
Applies constraints and refinements to a runtime value.
inherited
-
baseFieldsEqual(
AckSchema other) → bool -
Compares base schema fields for equality.
inherited
-
codec<
R extends Object> ({required R decode(Runtime value), required Runtime encode(R value), AckSchema< dynamic, R> ? output}) → CodecSchema<Boundary, R> -
Available on AckSchema<
Builds a bidirectional codec on top of this schema.Boundary, Runtime> , provided by the AckSchemaExtensions extension -
constrain(
Constraint< Runtime> constraint, {String? message}) → LazySchema<Boundary, Runtime> -
Adds a raw
constraintto the schema.inherited -
copyWith(
{bool? isNullable, bool? isOptional, String? description, List< Constraint< ? constraints, List<Runtime> >Refinement< ? refinements, int? maxDepth}) → LazySchema<Runtime> >Boundary, Runtime> -
Returns a copy of this schema with the given fields replaced.
override
-
describe(
String description) → LazySchema< Boundary, Runtime> -
Sets the description for the schema.
inherited
-
encode(
Runtime? value, {String? debugName}) → Boundary? -
Encodes a runtime value to a boundary value, throwing on failure.
inherited
-
encodeAsBoundary(
Runtime value, SchemaContext context) → SchemaResult< Boundary> -
Helper for schemas whose boundary == runtime: validates the runtime
value and, if it passes, returns it as the boundary value unchanged.
Only safe to call when
BoundaryandRuntimeare the same type.inherited -
encodeWithContext(
Runtime value, SchemaContext context) → SchemaResult< Boundary> -
Encodes a runtime value into a boundary value. The base class strips
nullbefore calling this; subclasses receive a non-nullvalue.override -
failNonNullable(
SchemaContext context) → SchemaResult< Runtime> -
Runtime-side non-nullable failure.
inherited
-
failNonNullableEncode(
SchemaContext context) → SchemaResult< Boundary> -
Encode-side non-nullable failure.
inherited
-
handleNullInput(
Object? inputValue, SchemaContext context) → SchemaResult< Runtime> ? -
Centralized null gate for the parse/validate paths. Returns null when
inputValueis non-null; otherwise returns Ok(null) if acceptsNull is true or a non-nullable failure.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullable(
{bool value = true}) → LazySchema< Boundary, Runtime> -
Marks the schema as nullable.
inherited
-
optional(
{bool value = true}) → LazySchema< Boundary, Runtime> -
Marks the schema as optional so the field can be omitted from an object.
inherited
-
parse(
Object? value, {String? debugName}) → Runtime? -
Parses and validates a value, throwing an AckException if it fails.
inherited
-
parseAs<
TOut extends Object> (Object? value, TOut map(Runtime? validated), {String? debugName}) → TOut -
Parses and validates a value, then maps the validated value to
TOut.inherited -
parseWithContext(
Object? value, SchemaContext context) → SchemaResult< Runtime> -
Decodes a boundary value into a runtime value.
override
-
refine(
bool validate(Runtime value), {String message = 'The value did not pass the custom validation.'}) → LazySchema< Boundary, Runtime> -
Adds a custom validation check that runs after all other validations.
inherited
-
safeEncode(
Runtime? value, {String? debugName}) → SchemaResult< Boundary> -
Encodes a runtime value to a boundary value, returning a SchemaResult.
inherited
-
safeParse(
Object? value, {String? debugName}) → SchemaResult< Runtime> -
Parses and validates a value, returning a SchemaResult.
inherited
-
safeParseAs<
TOut extends Object> (Object? value, TOut map(Runtime? validated), {String? debugName}) → SchemaResult< TOut> -
Parses and validates a value, then maps the validated value to
TOut.inherited -
toJsonSchema(
) → Map< String, Object?> -
Converts this schema to a JSON Schema Draft-7 representation.
inherited
-
toMap(
) → Map< String, Object?> -
override
-
toSchemaModel(
) → AckSchemaModel -
Available on AckSchema<
Boundary, Runtime> , provided by the AckSchemaModelExtension extension -
toString(
) → String -
A string representation of this object.
inherited
-
transform<
R extends Object> (R transformer(Runtime value)) → CodecSchema< Boundary, R> -
Available on AckSchema<
Maps the validated runtime value to a new runtime typeBoundary, Runtime> , provided by the AckSchemaExtensions extensionRin a parse-only direction. -
validateRuntimeWithContext(
Object? value, SchemaContext context) → SchemaResult< Runtime> -
Validates that
valueis a valid runtime value for this schema.override -
withConstraint(
Constraint< Runtime> constraint) → LazySchema<Boundary, Runtime> -
Adds a validation constraint to the schema.
inherited
-
withConstraints(
List< Constraint< newConstraints) → LazySchema<Runtime> >Boundary, Runtime> -
Adds a list of validation constraints to the schema.
inherited
-
withDefault(
Runtime defaultValue) → DefaultSchema< Boundary, Runtime> -
Wraps this schema in a DefaultSchema that supplies
defaultValuewhen the parse input is null. Object encode also injects encoded defaults for missing default-wrapped fields.inherited -
withRuntimeConfig(
{bool? isNullable, bool? isOptional, String? description, List< Constraint< ? constraints, List<Runtime> >Refinement< ? refinements}) → LazySchema<Runtime> >Boundary, Runtime> -
Returns a copy of this schema with runtime-side configuration replaced.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Constants
- defaultMaxDepth → const int
-
Default recursion cap applied to
Ack.lazyschemas that do not specify their own maxDepth.