validasi_gen 0.1.0-dev.3
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 #
generateAssemblebuild option and@ValidateClass(generateAssemble: ...)are renamed togenerateSchema.- 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?) toFieldContextenum (string,iterable,generic). Custom handlers need to implementsupportedContexts.
Added #
CustomRuleGenandAsyncCustomRuleGen— generate custom validation rules from@CustomRuleand@AsyncCustomRuleannotations.InlineGen— generate inline validation functions from@Inlineannotations.- Non-string type support in
OneOfhandler (int, double, bool, enum types). emitErrorandhelperMethodstoRuleGeninterface for centralized error emission.- Private
_<ClassName>Schemaclass implementingValidasiSchema<ClassName>with an explicitallocate(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
FieldContextfromValidate<T>type argument instead of named constructor names (Validate.string,Validate.iterable). - All handlers updated to use
FieldContextinstead of rawDartType?for type dispatch. - Error emission refactored into centralized
_Errorshelpers across all handlers.
0.1.0-dev.2 #
- Add cross-field validation support with
validateFieldsand related methods. - Add async validation support with
validateAsyncmethods in generated code. - Add
@RefineFnannotation withFailFn, remove old@Refine/@RefineAsync. - Prevent nested fields from being processed in
generateFromFormmethod. - 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,Nullablestring rules via direct Dart codegen (Level 2). - Add per-field validation: for each
@ValidateClass()type, emit a sealedXFields<V>hierarchy that extendsValidasiKey<X>fromvalidasi_annotation. - Each annotated or nested field becomes a public
XFieldNameFieldleaf, exposingname,extract(X owner), andvalidate(V? value). - Add
validateField<V>(XFields<V> field)on the generated extension, withVinferred from the field key. - Standalone usage is supported via the leaf directly:
XFields.email.validate('value'). - Pattern matching is exhaustive on the sealed
XFieldsfor downstream form libraries. - Existing
validate()is unchanged in behavior; codegen now shares the rule emission helpers. - Add
generateFieldsbuild option (defaulttrue) and matching@ValidateClass(generateFields: ...)per-class override. When set tofalse, theXFieldssealed class, the per-field leaves, and thevalidateField<V>method are not emitted — only the existingvalidate()extension is generated. - Per-class annotation takes precedence over the build-level default. A non-bool value in
build.yamlis rejected at builder construction with anInvalidGenerationSourceError.