Stacked-Org/stacked

[feature]: FormTextField validator function various data types such as numbers

0001arunsharma opened this issue · 4 comments

Is your feature request related to a problem? Please describe.

I find it somewhat challenging when dealing with the FormTextField validator function as it exclusively accepts strings, which can make the process a bit laborious.

Describe the solution you would like

would be appreciated it if the solution could encompass support for various data types such as numbers, in addition to strings.

Additional Context

FormTextField FormTextField({
String? name,
String? initialValue,
String? Function(String?)? validator,
dynamic Function()? customTextEditingController,
})

Hi @0001arunsharma , I think there is no need for this feature. The value is passed as a nullable String but in the function you can treat it as a number. For example, see on the documentation how we don't allow numbers on a input field using regex. An alternative could be to cast the value to a number and do the validation needed.

@ferrarafer @FilledStacks Apologizes for late response.
The documentation is clear to us but we are asking user to enter the price of product and we are validating the user input. So we thought instead of casting string as a number if we can define the parameters type in validator function will me more straight forward. As a workaround we can cast value as a number and doing the validation. Thanks

I see, since text can take anything it'll always be string. We could probably build a cast -> type generic style middleware for the validator, but that would be more work than doing the cast in the validator as it's needed.

Thanks for the response.