flod 1.0.3
flod: ^1.0.3 copied to clipboard
Strict, fast, type-safe data validation and transformation for Dart and Flutter.
1.0.3 #
Public-API hardening release. Fixes analyzer errors that appeared when consuming Flod from other apps (e.g. on ValidationException, abortEarly: true, Dio / DioException, FlodDefaultLocale) while following the documented README examples.
Fixed — public exports (package:flod/flod.dart) #
ValidationExceptionis now exported from the main library barrel.- Previously the class lived only under
lib/src/validators/exception_validator/validator_exception.dartand was used internally byparse/parseAsync/JsonGuard.parseJsonOrThrow/ Dio interceptor. - Consumers could not write
on ValidationException catch (e)afterimport 'package:flod/flod.dart'— the analyzer reportednon_type_in_catch_clause/undefined_class. - Examples and tests that imported the private
src/path no longer need that workaround; they use the public export.
- Previously the class lived only under
FlodDefaultLocaleis now exported from the main library barrel.- Previously only reachable via
lib/src/i18n/default_locale.dart. - Documented i18n setup (
return FlodDefaultLocale.compile(code, params)) now type-checks for downstream packages without private imports.
- Previously only reachable via
Fixed — abortEarly on the Parse API #
ValidatorExtensions.safeParse,parse,safeParseAsync, andparseAsyncnow accept an optional named parameter{bool? abortEarly}.- The flag is forwarded into
Validator.validate/AsyncValidator.validateAsync, matching:- schema-level
stopOnFirstError()/ objectabortEarly, and - the README example
schema.safeParse(data, abortEarly: true).
- schema-level
- Before this release, calling
safeParse(..., abortEarly: true)failed withundefined_named_parametereven though low-levelvalidate(..., abortEarly: …)already supported it. - Added a regression test: per-call
abortEarly: truereturns a single error on multi-field object failure (same behavior asstopOnFirstError()).
Fixed — Dio integration entry point (package:flod/dio.dart) #
- Re-exports the entire
package:dio/dio.dartsurface alongsideFlodValidateInterceptor. - A single
import 'package:flod/dio.dart'now resolvesDio,DioException,Interceptor,Response, etc., so handler code can catch validation failures without a separate Dio import:} on DioException catch (e) { if (e.error is ValidationException) { /* ... */ } } - Before this release, importing only
package:flod/dio.dartleftDio/DioExceptionundefined (undefined_function/undefined_class/non_type_in_catch_clause).
Changed — docs & examples #
- README entry-points table documents the new exports and Dio re-export.
- Parse / JsonGuard / Dio / i18n sections clarify public types and
parseJsonvsparseJsonOrThrow. - Package examples (
example/flod_example.dart,example/high_ex.dart) and tests no longer import privatesrc/paths forValidationException.
Migration (from ≤ 1.0.2) #
| Before (broken / private) | After (1.0.3) |
|---|---|
import '.../src/.../validator_exception.dart' |
import 'package:flod/flod.dart' — use ValidationException |
import '.../src/.../default_locale.dart' |
import 'package:flod/flod.dart' — use FlodDefaultLocale |
schema.stopOnFirstError() only for abort |
also safeParse(data, abortEarly: true) / parse(..., abortEarly: true) |
import 'package:dio/dio.dart' + package:flod/dio.dart |
import 'package:flod/dio.dart' alone is enough |
No breaking changes to existing method signatures beyond adding optional named parameters (abortEarly). Existing call sites continue to compile.