Skip to main content

jar 1.3.0 copy "jar: ^1.3.0" to clipboard
jar: ^1.3.0 copied to clipboard

Elegant Schema Validation for Flutter and Dart

Changelog #

All notable changes to the JAR validation library will be documented in this file.

1.3.0 [2026-06-29] #

Added #

  • Output channel — JarResult.value exposes the transformed/coerced/defaulted value, propagated through nested objects, arrays, and records (yup .cast() / zod .parse() style).
  • Collect-all validation — validateAll() returns every issue (vs. abort-early validate()); JarResult.issues is a typed List<JarIssue> of { path, code, message } with fully-qualified paths (a.b.0.c).
  • Error codes — every built-in validator tags its issue with a semantic code (required, too_small, invalid_type, ...), enabling i18n and programmatic handling.
  • .test() refinement — runs even on null (unlike .custom()), receives { parent, root, path } context, and can emit multiple issues via ctx.addIssue(message, {path, code}).
  • defaultTo(value) and catchValue(value) for default/fallback values.
  • Coercion — .coerce() on number, date, boolean, and string.
  • record — Jar.record(valueSchema, [keySchema]) for dynamic-key maps with per-entry paths.
  • enum / literal — Jar.enumValue(values) and Jar.literal(value).
  • .when upgrade — whenFn(field, (value, schema) => ...) and whenFields([...], (values, schema) => ...).
  • union / discriminatedUnion — Jar.union([...]) and Jar.discriminatedUnion(key, {...}).
  • Async — validateAsync() and .testAsync().
  • i18n — JarLocale.setLocale({code: message}) for centralized messages keyed by code.
  • Metadata — .label(), .meta(), .describe() for schema introspection.
  • tuple, intersection, and lazy (recursive schemas).
  • Per-type methods: string url/uuid/length/nonempty; number lessThan/moreThan/multipleOf/finite; array nonempty/compact/ensure.

Fixed #

  • .when no longer pollutes the schema instance. Condition builders mutated self, leaking validators across reused/shared schema instances (notably array items) — a Chef item could make a sibling Waiter item's field wrongly required. Validation now snapshots and restores the base rules around each branch.
  • Coercible types (number/date/boolean) return an invalid_type issue for incompatible input instead of throwing.

Changed #

  • validate gained optional positional path and root arguments: validate(value, [allValues, path, root]). Backward compatible for callers; code that overrides validate must widen its signature to match.
  • .test validators are now kept in a dedicated tests list (still applied during validation).

1.2.0 [2025-03-25] #

Added #

  • Cross-field validation with access to all form values
    • Enhanced custom() method to optionally accept allValues parameter for all schema types
    • Added context-aware validation for dependent fields
    • Improved propagation of values to nested schemas
  • Comprehensive test suite for cross-field validation scenarios
    • Simple field dependency tests
    • Multi-level field dependency tests
    • Password confirmation validation tests
    • Conditional required fields tests
  • Added object-level validation for complex field relationships

Changed #

  • Updated documentation to include cross-field validation examples
  • Improved error propagation in nested schemas

1.1.1 [2025-03-15] #

Fixed #

  • Improved type validation for arrays
    • Enhanced type checking for array elements
    • Fixed edge cases in array type validation
    • Added more robust type inference for mixed-type arrays

1.1.0 [2025-03-15] #

Added #

  • Custom validation support with .custom() method for all schema types
    • Added to string, number, boolean, date, array, object, and mixed schemas
    • Allows for complex, context-aware validation rules
    • Returns dynamic error messages based on validation conditions
  • Comprehensive test suite for custom validation scenarios
    • Basic validation tests for each schema type
    • Advanced validation tests for real-world scenarios
    • Complex conditional validation tests

Changed #

  • Updated documentation to include custom validation examples
  • Improved error handling for validation functions

1.0.0 [2025-03-04] #

Added #

  • Initial release of JAR validation library
  • Core schema types:
    • String validation with email, pattern matching, and transformations
    • Number validation with min/max, positive/negative, and integer checks
    • Boolean validation with true/false assertions
    • Date validation with past/future and min/max date ranges
    • Array validation with length constraints and element validation
    • Object validation with nested schemas and field requirements
    • Mixed type validation for flexible data structures
  • Conditional validation with .when() method
  • Schema composition with .merge() for multi-step forms
  • Field transformation capabilities
  • Comprehensive test suite
3
likes
110
points
33
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Elegant Schema Validation for Flutter and Dart

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on jar