ack library
ACK - A validation library for Dart
Inspired by Zod (TypeScript), provides type-safe schema validation with a fluent API for runtime data validation and transformation.
Classes
- Ack
- The main entry point for creating schemas with the Ack validation library.
- AckAdditionalPropertiesAllowed
- AckAdditionalPropertiesDisallowed
- AckAdditionalPropertiesModel
- AckAdditionalPropertiesSchema
- AckAllOfSchemaModel
- AckAnyOfSchemaModel
- AckArraySchemaModel
- AckBooleanSchemaModel
- AckIntegerSchemaModel
-
AckModelAdapter<
Boundary extends Object, Runtime extends Object, Model extends Object> - Connects a generated immutable model to an Ack schema.
- AckNullSchemaModel
- AckNumberSchemaModel
- AckObjectSchemaModel
- AckOneOfSchemaModel
- AckRefSchemaModel
-
AckSchema<
Boundary extends Object, Runtime extends Object> - The bidirectional schema contract.
- AckSchemaDiscriminatorModel
- AckSchemaModel
- AckSchemaModelWarning
- AckStringSchemaModel
- AnyOfSchema
- Schema for validating against a list of schemas (union).
- AnySchema
- Schema that accepts any non-null JSON-safe value.
- BooleanSchema
- Schema for validating boolean values.
-
BoundarySchema<
Boundary extends Object> - Validates with another schema while preserving the original boundary value.
-
CodecSchema<
Boundary extends Object, Runtime extends Object> - Codec schema for translating between a boundary value and a runtime value.
-
Constraint<
T> - Base class for all validation constraints.
- ConstraintError
- Represents an error that occurred due to a violated constraint.
-
DefaultSchema<
Boundary extends Object, Runtime extends Object> - Wraps another schema and supplies a runtime default when the input is null on parse. Object encode injects encoded defaults for missing default-wrapped fields.
-
DiscriminatedObjectSchema<
T extends Object> - Schema for validating a discriminated union of objects.
- DoubleSchema
- Schema for validating JSON number values as Dart doubles.
- DurationConstraint
- A constraint for validating Duration values against minimum and maximum bounds.
-
EnumSchema<
T extends Enum> -
Schema for validating enum values where the boundary is the enum's
.name(aString) and the runtime is the typed enum value. -
Fail<
T extends Object> - Represents a failed validation outcome, containing a SchemaError.
-
InstanceSchema<
T extends Object> -
Runtime-side schema that validates a Dart value is an instance of
T. - IntegerSchema
- Schema for validating JSON integer values.
- JsonSchemaImportDiagnostic
- A limitation or error found while importing a JSON Schema document.
-
LazySchema<
Boundary extends Object, Runtime extends Object> - Defers resolving another schema until parse, validation, encode, or export time.
-
ListSchema<
ItemBoundary extends Object, ItemRuntime extends Object> -
Schema for validating
List<ItemRuntime>whose items conform to itemSchema, with boundary typeList<ItemBoundary>. -
MapSchema<
ValueBoundary extends Object, ValueRuntime extends Object> - Schema for JSON objects with arbitrary string keys whose values all conform to valueSchema.
- NumberSchema
- Schema for validating any num value.
-
NumSchema<
T extends num> - Base schema for numeric types (integer, double, num).
- ObjectSchema
-
Schema for validating
JsonMapshaped values. -
Ok<
T extends Object> -
Represents a successful validation outcome, optionally wrapping a value.
The
_valuecan benullif the schema was nullable and the input was validly null. - SchemaConstraintsError
- SchemaContext
- Represents the context in which a schema operation is occurring.
- SchemaEncodeError
- Errors raised during the encode path (Runtime → Boundary).
- SchemaError
- SchemaNestedError
-
SchemaResult<
T extends Object> - Represents the outcome of a schema validation, which can either be a success (Ok) containing the validated value, or a failure (Fail) containing a SchemaError.
- SchemaTransformError
- SchemaValidationError
- StringSchema
- Schema for validating string values.
- TestUnsupportedAckSchema
- Testing-only schema used to simulate unsupported conversions in integration packages.
- TypeMismatchError
Enums
- DurationComparisonType
- Type of duration comparison operation to perform.
- SchemaEncodeFailureKind
- Categorizes encode-side failures so callers can react programmatically.
- SchemaType
- Schema type enumeration covering JSON primitives and schema-specific categories.
Mixins
-
FluentSchema<
Boundary extends Object, Runtime extends Object, Schema extends AckSchema< Boundary, Runtime> > -
Provides a fluent builder API for schemas with a strongly-typed
copyWith. -
JsonSchemaSpec<
T> - Mixin for constraints that can be converted to a JSON Schema representation.
-
Validator<
T> - Mixin defining the core validation logic for a Constraint.
Extensions
-
AckSchemaExtensions
on AckSchema<
Boundary, Runtime> - Core extensions for all AckSchema types.
-
AckSchemaModelExtension
on AckSchema<
Boundary, Runtime> -
DateTimeSchemaExtensions
on CodecSchema<
String, DateTime> -
Extensions for
CodecSchema<String, DateTime>to add date range validation. - DoubleSchemaExtensions on DoubleSchema
- Adds fluent validation methods to DoubleSchema.
-
DurationSchemaExtensions
on CodecSchema<
int, Duration> -
Extensions for
CodecSchema<int, Duration>to add range validation. - IntegerSchemaExtensions on IntegerSchema
- Adds fluent validation methods to IntegerSchema.
-
ListSchemaExtensions
on ListSchema<
ItemBoundary, ItemRuntime> - Adds fluent validation methods to ListSchema.
- NumberSchemaExtensions on NumberSchema
- Adds fluent validation methods to NumberSchema.
- ObjectSchemaExtensions on ObjectSchema
- Adds fluent validation methods to ObjectSchema.
- StringSchemaExtensions on StringSchema
- Adds fluent validation methods to StringSchema.
Functions
-
deepEquals(
Object? a, Object? b) → bool - Performs deep equality comparison between two values.
-
deepHashCode(
Object? value) → int -
Computes a hash code for
valuethat is consistent with deepEquals. -
deepUnmodifiableJsonMap(
JsonMap value) → JsonMap -
Returns a detached, recursively unmodifiable snapshot of
value. -
jsonMapOrNull(
Object? value) → JsonMap? -
Safely converts a value into a JsonMap. Returns
nullif the value is not map-shaped or contains non-string keys. This eager check replacescast<String, Object?>(), whose lazy semantics can throw at access time when a non-string key is hit.
Typedefs
Exceptions / Errors
- AckException
-
An exception thrown when schema validation fails using
parse(). - JsonSchemaImportException
- A strict import encountered a limitation, or the input cannot be imported.