k0shk0sh/ComposeEasyForms

Add ability to look at form level if my form is invalid

samdharris opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
Say you have a button on your form that you wish to have disabled until the associated form is considered valid by EasyForms, right now you have to check, every field's validation state. Which form a form as simple as a login form that's fine but for more complexed forms it can get a bit ugly 🙈

Describe the solution you'd like
It could be as simple as a method form.isValid() or a computed property form.isValid. It would look across a form and all of its field's errorState objects to ensure they are all valid.

Hi @samdharris thanks for opening the issue.

EasyForms already has this functionality, please have a look at the example app which does enable/disable CTA based on form state: https://github.com/k0shk0sh/ComposeEasyForms/blob/main/app/src/main/java/com/github/k0shk0sh/compose/easyforms/example/ui/MainActivity.kt#L120

If you like to manually check for the form validity, you can call: https://github.com/k0shk0sh/ComposeEasyForms/blob/main/easyforms/src/main/java/com/github/k0shk0sh/compose/easyforms/EasyForms.kt#L219