Skip to main content

validasi 1.0.0 copy "validasi: ^1.0.0" to clipboard
validasi: ^1.0.0 copied to clipboard

An easy to use and flexible validation library for Dart and Flutter. Easily validate your forms input with built-in rules or create your own.

Changelog #

1.0.0 #

  • Promote 1.0.0-rc.6 to stable. No API changes.
  • Ship the validasi-guide Agent Skill inside the package, discoverable with dart run skills@ get.

1.0.0-rc.6 #

Changed #

  • Widened the build_runner dev constraint to >=2.4.12 <3.0.0 so the workspace resolves the latest build_runner 2.x alongside newer analyzer/test releases (e.g. in Flutter projects using validasi_gen). No runtime changes.

1.0.0-rc.5 #

Fixed #

  • Rules.map.hasFields() / HasFields now carry the map value generic (HasFields<T> extends Rule<Map<String, T>>), matching every other map rule. Previously HasFields was hardcoded to Rule<Map<String, dynamic>>, so it only fit Validasi.map<dynamic>() and failed to compile inside a typed map such as Validasi.map<int>(). Source-compatible: an omitted type argument defaults to dynamic, so existing call sites are unchanged.

1.0.0-rc.4 #

Added #

  • ValidationState is now publicly exported from package:validasi/rules.dart, making custom rule authoring possible without importing src/ internals.
  • Rule<T> and AsyncRule<T> are now publicly exported from package:validasi/validasi.dart (previously only available via package:validasi/rules.dart).

Changed #

  • Custom rules now only need import 'package:validasi/validasi.dart'; instead of three separate src/engine/ imports. Updated all documentation and examples accordingly. Bumps rc.3 → rc.4 since it's a small additive change to the public API surface.

1.0.0-rc.3 #

Added #

  • ValidasiFieldReader<T> abstraction for reading field values without depending on Flutter.
  • ValidasiSchema<T> abstraction with an explicit allocate(ValidasiFieldReader<T>) method for building typed models from form field values.

1.0.0-rc.2 #

Added #

  • ValidasiKey<T> is now available from package:validasi/validasi.dart (marked @experimental). This type bridges the code generation layer and runtime form management. Prefer using the generated sealed field classes over referencing ValidasiKey directly.

1.0.0-rc.1 #

Added #

  • keySelector parameter to Rules.iterable.contains(), Rules.iterable.notContains(), Rules.iterable.containsAll(), and Rules.iterable.unique() for O(k) key-based lookups.
  • hasher parameter to Rules.iterable.unique() for LinkedHashSet-based O(N) uniqueness checks with custom equality.
  • Mutating ValidationError.prefix() for zero-allocation path prefixing in container rules (ForEach, HasFields, AllValues).
  • Comprehensive nested path tests covering 2-level and 3-level container nesting (HasFields ⇄ ForEach ⇄ AllValues).

Changed #

  • withPreprocess now accepts a plain function instead of ValidasiTransformation. Removed the ValidasiTransformation class and the transformer.dart export.

    // Before
    .withPreprocess(ValidasiTransformation<String, int>((s) => int.parse(s)))
    
    // After
    .withPreprocess((String s) => int.parse(s))
    
  • Contains, NotContains replaced equals with keySelector parameter.

  • ContainsAll replaced equals with keySelector parameter for O(N+M) Set-based lookups.

  • Unique replaced equals with keySelector and optional hasher + equals for LinkedHashSet-based O(N) checks (O(N²) fallback for equals without hasher).

  • ValidationError.withPrefix() → mutating ValidationError.prefix() — eliminates error object allocations per prefix call.

  • Optimized allowed_keys, forbidden_keys, has_field_keys, required_all, required_one_of with early-exit and lazy iteration patterns.

  • ForEach, HasFields, AllValues use mutating prefix() instead of withPrefix().

Performance #

  • Iterable membership checks: O(N²) → O(k) for contains/notContains, O(N×M) → O(N+M) for containsAll, O(N²) → O(N) for unique.
  • Path prefixing in container rules: no error object allocations per prefix.
  • Map key checks: lazy .where() instead of .where().toList(), early-exit in required_one_of, value.containsKey instead of keys.where in forbidden_keys.

1.0.0-dev.6 #

Added #

  • AsyncRule<T> base class for inherently async validation rules.
  • ValidasiEngine.validateAsync() and executeAsync() for async validation pipelines.
  • applyRulesAsync() helper for sequential async rule processing.
  • AsyncInlineRule<T> — async custom inline validator (Rules.inlineAsync()).
  • AsyncTransform<T> — async value transformation (Rules.transformAsync()).
  • AsyncConditionalField<T> — async conditional map validation (Rules.map.conditionalFieldAsync()).
  • Container rules (HasFields, ForEach, AllValues, AnyOf) now support async child rules via applyAsync() overrides.
  • All sync rules automatically work in async pipelines via the inherited default applyAsync().

Changed #

  • Rule<T> now includes Future<T?> applyAsync(...) defaulting to sync apply().
  • @pragma('vm:prefer-inline') added to executeAsync() and applyRulesAsync().

1.0.0-dev.5 #

Breaking Changes #

  • Unified Rules class replaces StringRules, IterableRules, NumberRules, MapRules.
    • StringRules.minLength(...) → Rules.string.minLength(...)
    • IterableRules.forEach(...) → Rules.iterable.forEach(...)
    • NumberRules.moreThanEqual(...) → Rules.number.moreThanEqual(...)
    • MapRules.hasFields(...) → Rules.map.hasFields(...)

Added #

  • Generic rules: Equals, NotEquals, AnyOf
  • String rules: startsWith, endsWith, contains, regex, lowercase, uppercase, alpha, alphanumeric, numeric, uuid, ulid, ip, ipv4, ipv6, url, email
  • Number rules: integer, decimal, positive, negative, nonNegative, nonPositive, between
  • Iterable rules: contains, notContains, containsAll, unique, isEmpty, isNotEmpty, exactLength
  • Map rules: allValues, allowedKeys, forbiddenKeys, minKeys, maxKeys, requiredAny, requiredOneOf, requiredAll, dependsOn, mutuallyExclusive, matchesField

1.0.0-dev.4 #

Added #

  • @pragma('vm:prefer-inline') to execute() and applyRules() for better performance (up to 10%).

Changed #

  • Removed agent-native support documentation and related code.
  • Updated documentation to reflect newer version.

1.0.0-dev.3 #

Changed #

  • Replaced direct state.errors.add calls with state.addError for consistent error handling.

1.0.0-dev.2 #

Added #

  • FieldRules class for lightweight field validation rules (replaces ValidasiEngine per field).
  • Benchmarks for hasFields comparison.

Changed #

  • HasFields now uses FieldRules instead of ValidasiEngine per field.
  • ForEach now accepts List<Rule<I>> directly instead of ValidasiEngine.
  • Code formatting for improved readability.

1.0.0-dev.1 #

Added #

  • ValidationState class with lazy error allocation, managing validation errors and state.
  • applyRules() top-level function as a reusable rule iteration primitive.
  • execute() internal method separating the validation pipeline from result wrapping.
  • Comprehensive benchmarks for List, Map, NestedMap, Number, String, StringTransform, and Preprocess.

Changed #

  • Migrated all rules, engine, and tests from ValidationContext to ValidationState.
  • Removed ValidationContext class entirely.
  • Rule apply method signature changed to T? apply(T? value, ValidationState state).
  • Nullable rule now sets state.isStopped = true directly instead of calling context.stop().
  • Engine rule iteration optimized to use const [] for empty rule lists.
  • Improved error handling in validation process.

1.0.0-dev.0 #

This is the v1 development release of Validasi. It is a major rework of the library and is not source-compatible with the 0.0.x series.

Added #

  • Agent-native schema introspection contracts:
    • RuleMetadata
    • SchemaDescriptor
    • ValidasiEngine.introspect()
  • Deterministic tool payload APIs:
    • ValidationError.toToolMap()
    • ValidasiResult.toToolResponse()
  • New adapter package: packages/validasi_mcp
    • JSON-RPC stdio server with MCP methods initialize, tools/list, and tools/call
    • Tools: list_schemas, describe_schema, validate_input
    • Registry and handler APIs for embedding
  • Expanded built-in rule coverage:
    • Strings: oneOf
    • Numbers: Finite, LessThan, LessThanEqual, MoreThan, MoreThanEqual
    • Maps: HasFields, HasFieldKeys, ConditionalField
    • Iterables: ForEach, MinLength
    • Generic: Having, InlineRule, Nullable, Required
    • Transformer: Transform
  • any() helper for flexible validation

Changed #

  • Reworked the validation core around the new engine, cache, and generic context model.
  • Moved the core package into packages/validasi.
  • Refreshed the documentation set and examples for the new API surface.

Fixed #

  • Nullable runtime checks now return the expected validation error.
  • Finite-rule type handling and condition checks were corrected.
  • Documentation links, image paths, and README references were cleaned up.

0.0.1 #

Initial release of Validasi library. This release includes the following features:

  • Built-in validators for common data types
  • Object and Array schema for complex data validation
  • Transformer to convert input value into desired format
  • Safe validation using tryParse and tryParseAsync method
  • Custom rule support

0.0.2 #

This release includes the following changes:

  • Update documentation: fix typo customAsync to custom, add validateAsync to Helpers section
  • Adjust validation(core): ensure rules are unique by using Map, so when rule registered more than once, the old one will be replaced
  • Adjust validator test (core): introduce should only register rule once test and adjust the rules from array to map
  • Update package description to meet dart package criteria
  • Update image in README.md to use absolute link

0.0.3 #

Minor release to update the following:

  • Expose FailFn, CustomRule, CustomCallback API

0.0.4 #

This release introduce GenericValidator, add some rules for Array Validation, and add some methods for Object Validation.

  • Add max, notContains, contains, and unique rule for ArrayValidator.
  • Add extend and without method for ObjectValidator.
  • Add new GenericValidator through Validasi.generic<T>(transformer) to help validate any type.

0.0.5 #

This release introduce breaking changes! It simplifies the FieldValidator and GroupValidator Helpers API from previously when used in flutter:

var group = GroupValidator({
    'example': Validasi.string()
})

TextFormField(
  validator: (v) => FieldValidator(Validasi.string()).validate(v, path: 'Custom Path'),
)

TextFormField(
    validator: (v) => group.validate('example', v)
)

To a more simpler API:

var group = GroupValidator({
    'example': Validasi.string()
})

TextFormField(
  validator: FieldValidator(Validasi.string(), path: 'Custom Path').validate,
)

TextFormField(
    validator: group.on('example', path: 'Custom Path').validate
)

This means the previous code is not longer valid and should be updated to the new API.

Affected methods:

  • FieldValidator.validate
  • GroupValidator.validate

0.0.6 #

What's Changed #

New Contributors #

Full Changelog: https://github.com/albetnov/validasi/compare/v0.0.5...v0.0.6

0.0.7 #

What's Changed #

  • feat(string/url): Enhance url validation adding checks for validating schema and host using UrlChecks enum
  • chore(docs): Add checks to url method in string.md documentation
  • chore(docs): Updated Quick Start guide in doc/quick-start.md to include Flutter example

Full Changelog: https://github.com/albetnov/validasi/compare/v0.0.6...v0.0.7

0.0.8 #

What's Changed #

  • rewrite most of GroupValidator code for better maintainability and readability
  • Renamed on method to using to improve clarity
  • Added extend method to allow extending the existing validator in group
  • New validateMap and validateMapAsync methods to validate a map of values against the group schema.

Breaking Changes #

  • on method in GroupValidator has been renamed to using. Update your code accordingly.
  • Invalid field will return ValidasiException("Field '$field' is not found in the schema"). Impacted method (validate, validateAsync)
  • Unset field will return ValidasiException("Field is not set. Use 'using' method to set the field."). Impacted method (validate, validateAsync)

Full Changelog: https://github.com/albetnov/validasi/compare/v0.0.7...v0.0.8

0.0.9 #

What's Changed #

  • Refactored using method to return GroupValidatorUsing instead of GroupValidator to improve DX and better isolation

Breaking Changes #

  • using method in GroupValidator now returns GroupValidatorUsing instead of GroupValidator. Update your code accordingly.
  • validate and validateAsync methods in GroupValidator is now removed. It could only be used in GroupValidatorUsing class.
// before
GroupValidator(...).validate(); // static check: OK
// after
**Full Changelog**: https://github.com/albetnov/validasi/compare/v0.0.7...v0.0.8
GroupValidator(...).using('field').validate(); // static check: OK
GroupValidator(...).validate(); // static check: ERROR

Full Changelog: https://github.com/albetnov/validasi/compare/v0.0.8...v0.0.9

1
likes
150
points
701
downloads

Documentation

API reference

Publisher

verified publisheralbetnv.dev

Weekly Downloads

An easy to use and flexible validation library for Dart and Flutter. Easily validate your forms input with built-in rules or create your own.

Homepage
Repository (GitHub)
View/report issues

Topics

#validation #form

License

MIT (license)

Dependencies

intl, meta

More

Packages that depend on validasi