artflutter / reactive_forms_generator

Other
88 stars 22 forks source link

FormArrayAnnotation validators have mismatching type #65

Closed ahmednfwela closed 2 weeks ago

ahmednfwela commented 1 year ago

when generating a model with @FormArrayAnnotation<TModel> (not just @FormArrayAnnotation()) the validators assume it's a FormArray<TModel>, but the generated code is always FormArray<Map<String, Object?>>

e.g.: if this was @FormArrayAnnotation<UrlEntity>(validators: [someValidator]) https://github.com/artflutter/reactive_forms_generator/blob/master/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url.dart#L10

then this would fail https://github.com/artflutter/reactive_forms_generator/blob/master/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url.gform.dart#L444-L446

because the actual type is https://github.com/artflutter/reactive_forms_generator/blob/master/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url.gform.dart#L349-L350

vasilich6107 commented 1 year ago

Hi Will check

ahmednfwela commented 1 year ago

any news on this ? @vasilich6107

vasilich6107 commented 1 year ago

Hi. Sorry for delay. Answered quick issues. You's next)

vasilich6107 commented 1 year ago

Hi @ahmednfwela For now typed annotation combined with Array of FormGroups should be considered as known limitation. Please fallback to untyped annotations.

FormArray of FormGroups value is deeply nested map so it does not seem to be very easy to mimic the typed behaviour

image
colunira commented 1 year ago

Would it be possible to provide untyped validators to work around this limitation with typing enabled everywhere but validators?

vasilich6107 commented 1 year ago

@colunira the default type is dynamic just omit type in annotation

github-actions[bot] commented 2 weeks ago

Hi @ahmednfwela! 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