diff --git a/docs/forms/com.nwagu.forms.utils/index.html b/docs/forms/com.nwagu.forms.utils/index.html new file mode 100644 index 0000000..b7109bd --- /dev/null +++ b/docs/forms/com.nwagu.forms.utils/index.html @@ -0,0 +1,103 @@ + + +
+ +This object contains some form field validators that are commonly needed in forms.
If any of them do not meet your needs (for instance, maybe the email address regex is too permissive), then you should write your own custom validators and use those instead. You can also make a pull request to add to this file any validators you think would be useful to others.
Whether this form field is optional or not. If true, the form field value is required to be non-null or non-empty to be validated. If false, the field value is optional and will be valid if it is empty or null.
Note that if required is false and the value of this form field is neither null nor empty, the field will be validated as if it were required.
The initial value of this form field. Would typically be null or an empty string unless the form field is pre-filled (no pun intended).
Add multiple validators to this form field.
Add multiple validators to this form field.
If this is false, the form field's error state flow value will always be null.
This is used to achieve a good UX with 'out of focus' error reporting. Set this field to true, for example after the edit text loses focus, so that the error messages for the form field can start being emitted.
This emits a Unit value when the field is to be brought to the user's attention.
It is updated by the parent form when this form field fails validation.
A FormField is a MutableStateFlow, so it can be collected and its value updated like any other MutableStateFlow.
But it also has parameters that make it suitable for use in a form, such as validators, error stateflow, feedback stateflow, and focus request.
Form field validators are run in the order they are added to the form field. If a validator fails, the remaining validators are not run. If you make use of the feedback property, it might be best practice to add only one validator.
Whether this form field is optional or not. If true, the form field value is required to be non-null or non-empty to be validated. If false, the field value is optional and will be valid if it is empty or null.
Note that if required is false and the value of this form field is neither null nor empty, the field will be validated as if it were required.
The initial value of this form field. Would typically be null or an empty string unless the form field is pre-filled (no pun intended).
If this is false, the form field's error state flow value will always be null.
This emits a Unit value when the field is to be brought to the user's attention.
Add multiple validators to this form field.
Add multiple validators to this form field.
Whether this form field is optional or not. If true, the form field value is required to be non-null or non-empty to be validated. If false, the field value is optional and will be valid if it is empty or null.
Note that if required is false and the value of this form field is neither null nor empty, the field will be validated as if it were required.
A coroutine scope, used for observing the form fields and updating the isComplete state.
Add multiple form fields at once.
A form is a list of FormFields with methods to manage them (add, remove, verify, etc).
Forms can be used for single text inputs like in a login form, or for more complex scenarios like image selection and upload to a service.
A coroutine scope, used for observing the form fields and updating the isComplete state.
Add multiple form fields at once.
Remove a form field.
Remove multiple form fields at once.
State flow that is true if all the form fields in this form are valid.
Collect this state flow to for instance enable or disable a submit button, continue button, etc.
Remove a form field.
Remove multiple form fields at once.
Use this function when you want to validate the entire form, for instance when the user clicks a submit button.
Runs validators for all the form fields in this form, until one fails; enables error reporting for the failed field.
Also triggers a focus request for the failed field, which can be observed to bring the failed field to the user's attention.
true if all the form fields are valid, false otherwise.
Validators are extension functions for validating form fields
The type of the form field
FormFieldValidationResult representing the result of the validation.
This object contains some form field validators that are commonly needed in forms.
Validators are extension functions for validating form fields