Zema Logo

Schema validation for Dart. Define once, validate anywhere.

Zema is a schema validation library for Dart inspired by Zod. A fluent chainable API, exhaustive error collection, and a sealed result type that never throws unless you want it to.

Everything you need to validate data in Dart

    Fluent chainable API
    Build schemas by chaining constraints: z.string().min(2).email(). Every method returns a new immutable schema instance: no mutation, no side effects.
    Exhaustive error collection
    Every failing field is reported in a single parse call. No silent failures, no early exits. Each issue carries a code, a human-readable message, and a path to the exact location in the input.
    Sealed result type
    safeParse() returns ZemaSuccess<T> or ZemaFailure<T>, never throws. Use Dart 3 pattern matching to handle both cases. Call parse() when you prefer an exception on failure.
    Composable object schemas
    Build complex schemas from simple ones. extend(), merge(), pick(), and omit() let you derive new schemas from existing ones without repetition.
    Discriminated unions
    discriminatedBy() selects the matching schema directly from a literal field, O(1) instead of a linear scan. No unnecessary validation of non-matching schemas.
    Coercion for raw inputs
    z.coerce() converts strings from environment variables, query parameters, and form inputs into the correct Dart type before validation runs.
Copyright © 2026