API Reference

This page provides a quick reference for the core Ack classes, methods, and annotations. For detailed explanations and usage examples, refer to the specific guides linked below.

Core Ack Class

Entry point for creating schemas. See Schema Types.

AckSchema<T> (Base Class)

Base class for all schema types.

See also TypeSafe Schemas for working with schemas and Dart models.

IntSchema / DoubleSchema (Number Schemas)

Schemas for validating numbers. See Number Constraints.

BooleanSchema

Schema for validating booleans. See Boolean Schema. No specific constraints beyond type.

ObjectSchema

Schema for validating objects (maps). See Object Schema.

  • Constructed using Ack.object(...).
  • Configuration includes properties, required, additionalProperties.

Result<T>

Object returned by validate(). See The Result Object.

  • bool isOk
  • bool isFail
  • T getOrThrow()
  • T? getOrNull()
  • SchemaError? getError()
  • T getOrElse(T Function() defaultValue)

SchemaError (and Subclasses)

Object representing a validation failure. See Understanding SchemaError and Error Types.

  • String name
  • String message
  • List<String> path
  • dynamic value
  • dynamic expected

Subclasses: SchemaTypeError, SchemaRequiredError, SchemaConstraintsError, SchemaNestedError.

SchemaConstraint<T>

Base class for creating custom validation rules. See Custom Validation Guide.

  • SchemaConstraint({required String name, required String message})
  • bool validate(T value, [Map<String, dynamic>? data])

Code Generation (ack_generator)

Annotations for use on model classes when using code generation. See Code Generation Guide.

Class Annotations: @Schema(...)

Property Annotations: @Required, @Nullable, @Description, @IsEmail, @IsUrl, @IsDate, @IsDateTime, @MinLength, @MaxLength, @Length, @Matches, @Contains, @IsNotEmpty, @EnumValues, @Min, @Max, @Positive, @Negative, @MultipleOf, @MinItems, @MaxItems, @UniqueItems.

Refer to the individual guides for detailed usage and examples.