validateForm method

Future<FormX<T>> validateForm({
  1. bool softValidation = false,
})

Validates all fields in the form

Returns a new state with all fields validated and when softValidation is true, it doesn't add errors messages to the fields, but updates the value of FormXState.isFormValid which can be used to show a submit button as enabled or disabled

Implementation

Future<FormX<T>> validateForm({bool softValidation = false}) async {
  final inputMap = _cloneStateMap;
  await Future.forEach(inputMap.keys, (key) async {
    inputMap[key] =
        await inputMap[key]!.validateItem(softValidation: softValidation);
  });

  return FormX<T>._(inputMap);
}