validate method

bool validate()

Validates all FormCraftTextField widgets and returns true if all are valid.

Iterates through each field, validates its content, and returns a boolean indicating overall validity.

Implementation

bool validate() {
  // List to store the validation results for each field
  var validate = <bool>[];
  _globalKeys.forEach((key, value) {
    // Validate the current field and add the result to the list
    final isValid = _globalKeys[key]!.currentState!.validate();
    validate.add(isValid);
  });

  // Return true if all fields are valid, false otherwise
  return validate.every((element) => element);
}