validasi_gen 1.0.0-rc.1
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.dartto.validasi.dartto avoid build conflicts with otherbuild_runnergenerators (e.g.json_serializable) sharing.g.dart. Existingpart 'x.g.dart';directives must be updated topart 'x.validasi.dart';and projects must regenerate (dart run build_runner build --delete-conflicting-outputs).
0.1.0-dev.6 #
Added #
- Auto-discovery of
formValidatormethods 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
getValuecalls
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 viaCrossFieldSugarGenerator CrossFieldRuleParserfor 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 #
RefineMethodInfonow includesruleNamefield for per-rule error tagging- Generated
$failclosures 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._validateCustomClassinstead of_validateCustomClass)
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.