validasi_gen 0.1.0-dev.3 copy "validasi_gen: ^0.1.0-dev.3" to clipboard
validasi_gen: ^0.1.0-dev.3 copied to clipboard

Code generator for Validasi - compile-time validation with zero-cost abstraction.

0.1.0-dev.3 #

Breaking Changes #

  • generateAssemble build option and @ValidateClass(generateAssemble: ...) are renamed to generateSchema.
  • Generated top-level assemble_<ClassName>() functions are removed. Generated schemas are now exposed as <ClassName>Fields.schema (ValidasiSchema<ClassName>).
  • Handler infrastructure migrated from typeArg (DartType?) to FieldContext enum (string, iterable, generic). Custom handlers need to implement supportedContexts.

Added #

  • CustomRuleGen and AsyncCustomRuleGen — generate custom validation rules from @CustomRule and @AsyncCustomRule annotations.
  • InlineGen — generate inline validation functions from @Inline annotations.
  • Non-string type support in OneOf handler (int, double, bool, enum types).
  • emitError and helperMethods to RuleGen interface for centralized error emission.
  • Private _<ClassName>Schema class implementing ValidasiSchema<ClassName> with an explicit allocate(ValidasiFieldReader<ClassName>) method.
  • Custom rule example in the validasi_gen example app.
  • Any validation generation tests covering Inline, OneOf, CustomRule with enum, int, and async types.

Changed #

  • Rules parser computes FieldContext from Validate<T> type argument instead of named constructor names (Validate.string, Validate.iterable).
  • All handlers updated to use FieldContext instead of raw DartType? for type dispatch.
  • Error emission refactored into centralized _Errors helpers across all handlers.

0.1.0-dev.2 #

  • Add cross-field validation support with validateFields and related methods.
  • Add async validation support with validateAsync methods in generated code.
  • Add @RefineFn annotation with FailFn, remove old @Refine/@RefineAsync.
  • Prevent nested fields from being processed in generateFromForm method.
  • Refactor field generation and validation logic; improve codegen formatting.
  • Add support for indexed fields in validation framework.
  • Update docs and improve generated code formatting.

0.1.0-dev.1 #

  • Initial development release.
  • Generates validate() extension method for @ValidateClass() annotated classes.
  • Supports MinLength, MaxLength, OneOf, Required, Nullable string rules via direct Dart codegen (Level 2).
  • Add per-field validation: for each @ValidateClass() type, emit a sealed XFields<V> hierarchy that extends ValidasiKey<X> from validasi_annotation.
  • Each annotated or nested field becomes a public XFieldNameField leaf, exposing name, extract(X owner), and validate(V? value).
  • Add validateField<V>(XFields<V> field) on the generated extension, with V inferred from the field key.
  • Standalone usage is supported via the leaf directly: XFields.email.validate('value').
  • Pattern matching is exhaustive on the sealed XFields for downstream form libraries.
  • Existing validate() is unchanged in behavior; codegen now shares the rule emission helpers.
  • Add generateFields build option (default true) and matching @ValidateClass(generateFields: ...) per-class override. When set to false, the XFields sealed class, the per-field leaves, and the validateField<V> method are not emitted — only the existing validate() extension is generated.
  • Per-class annotation takes precedence over the build-level default. A non-bool value in build.yaml is rejected at builder construction with an InvalidGenerationSourceError.
0
likes
140
points
202
downloads

Documentation

API reference

Publisher

verified publisheralbetnv.dev

Weekly Downloads

Code generator for Validasi - compile-time validation with zero-cost abstraction.

Homepage
Repository (GitHub)
View/report issues

Topics

#validation #codegen #annotations

License

MIT (license)

Dependencies

analyzer, build, code_builder, dart_style, source_gen

More

Packages that depend on validasi_gen