validasi_gen 1.0.0-rc.1 copy "validasi_gen: ^1.0.0-rc.1" to clipboard
validasi_gen: ^1.0.0-rc.1 copied to clipboard

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

1.0.0-rc.1 #

Breaking Changes #

  • Generated output extension changed from .g.dart to .validasi.dart to avoid build conflicts with other build_runner generators (e.g. json_serializable) sharing .g.dart. Existing part 'x.g.dart'; directives must be updated to part 'x.validasi.dart'; and projects must regenerate (dart run build_runner build --delete-conflicting-outputs).

0.1.0-dev.6 #

Added #

  • Auto-discovery of formValidator methods in generated schema classes
  • Async validation support for individual fields with coordinated submit handling
  • Static method requirement enforcement for cross-field validation

Changed #

  • Name collision prevention: static accessors and helper methods now suffixed with underscores
  • Enhanced type safety by adding type arguments to getValue calls

0.1.0-dev.5 #

Fixed #

  • Update null safey checks in validatoin handlers to avoid cannot be promoted error

0.1.0-dev.4 #

Added #

  • Codegen handlers for all new validation annotations: string (Alpha, Alphanumeric, Numeric, Lowercase, Uppercase, StartsWith, EndsWith, Regex, Ulid, Uuid, Url, Ip, Ipv4, Ipv6, Email, Contains), numeric (Between, LessThan, LessThanEqual, MoreThan, MoreThanEqual, Negative, NonNegative, NonPositive, Positive, Finite), iterable (ExactLength, IsEmpty, IsNotEmpty, Unique, ContainsAll, NotContains), and generic (Equals, NotEquals, Having)
  • Cross-field annotation codegen — class-level annotations (@RequiredAny, @RequiredOneOf, @RequiredAll, @DependsOn, @MutuallyExclusive, @MatchesField) desugar into synthetic emit-fn methods via CrossFieldSugarGenerator
  • CrossFieldRuleParser for extracting cross-field rules from class-level annotations
  • All fields (not just validated ones) are included in the validate extension for cross-field access

Changed #

  • RefineMethodInfo now includes ruleName field for per-rule error tagging
  • Generated $fail closures use unique names per refine method to avoid collisions
  • Inline and async_inline handlers use qualifiedFunctionName() to correctly qualify static method references

Fixed #

  • Inline rule codegen now correctly qualifies static method names with the enclosing class (e.g. User._validateCustomClass instead of _validateCustomClass)

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
19
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