artflutter / reactive_forms_generator

Other
81 stars 22 forks source link

Generated classes missing RfGroup validators. #133

Closed TortillaZHawaii closed 9 months ago

TortillaZHawaii commented 9 months ago

I tried to create a group wide validator similar to what was found in https://github.com/artflutter/reactive_forms_generator/blob/master/packages/reactive_forms_generator/example/lib/docs/login_extended/login_extended.dart example.

However it seems that RfGroup validators aren't passed to generated classes.

Repo with recreated bug: https://github.com/TortillaZHawaii/reactive_forms_bug. I am using latest versions:

dependencies:
  reactive_forms: ^16.1.0
  reactive_forms_annotations: ^4.0.0
dev_dependencies:
  reactive_forms_generator: ^4.0.1
  build_runner: ^2.4.6

File lib/login.dart contains MyMustMatchValidator, but it isn't seen anywhere in generated lib/login.gform.dart file.

I found a workaround that requires manually copying validators from RfGroup to formElements method in generated file.

vasilich6107 commented 9 months ago

hi. thanks for the reproduction will check

vasilich6107 commented 9 months ago

for now you can do

const loginMustMatchValidator = MyMustMatchValidator(
    controlName: 'password',
    matchingControlName: 'confirmPassword',
  );
@RfGroup(validators: [
  loginMustMatchValidator,
])
vasilich6107 commented 9 months ago

fixed in reactive_forms_generator 4.0.2

github-actions[bot] commented 9 months ago

Hi @TortillaZHawaii! Your issue has been closed. If we were helpful don't forget to star the repo.

Please check our reactive_forms_widget package

We would appreciate sponsorship subscription or one time donation https://github.com/sponsors/artflutter

TortillaZHawaii commented 9 months ago

Thanks!