23 lines
851 B
Dart
23 lines
851 B
Dart
// * Utility class for validating required form fields
|
|
// * Used to check if all required fields have been filled out
|
|
// * before saving or submitting form data
|
|
|
|
/// Helper class for form field validation
|
|
class CheckRequired {
|
|
/// Check if any required fields are empty
|
|
/// @param fieldsList Map of field definitions with their required status and controllers
|
|
/// @return true if any required field is empty, false otherwise
|
|
static bool checkRequired(Map<String, Map<String, dynamic>> fieldsList) {
|
|
// Iterate through all fields
|
|
for (String key in fieldsList.keys) {
|
|
// Check if field is required and empty
|
|
if (fieldsList[key]!["required"]! && fieldsList[key]!["controller"]!.text.isEmpty) {
|
|
return true; // Found an empty required field
|
|
}
|
|
}
|
|
|
|
return false; // All required fields are filled
|
|
}
|
|
}
|
|
|