Merge pull request 'fix: Enhance contact number validation in organization form' (#43) from Vaibhav_Bug-#452 into main
Reviewed-on: #43
This commit is contained in:
commit
4862e53967
@ -275,7 +275,21 @@ class _OrganizationFormState extends State<_OrganizationForm> {
|
|||||||
Widget _buildTextField(String fieldName, String label,
|
Widget _buildTextField(String fieldName, String label,
|
||||||
{TextInputType keyboardType = TextInputType.text}) {
|
{TextInputType keyboardType = TextInputType.text}) {
|
||||||
final controller = validator.getController(fieldName);
|
final controller = validator.getController(fieldName);
|
||||||
final validatorFunc = validator.getValidation<String>(fieldName);
|
final defaultValidator = validator.getValidation<String>(fieldName);
|
||||||
|
|
||||||
|
// Custom logic for contact number
|
||||||
|
String? Function(String?)? validatorFunc = defaultValidator;
|
||||||
|
if (fieldName == 'contactNumber') {
|
||||||
|
validatorFunc = (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return 'Contact number is required';
|
||||||
|
}
|
||||||
|
if (!RegExp(r'^\d{10}$').hasMatch(value)) {
|
||||||
|
return 'Enter a valid 10-digit contact number';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||||
@ -289,7 +303,8 @@ class _OrganizationFormState extends State<_OrganizationForm> {
|
|||||||
validator: validatorFunc,
|
validator: validatorFunc,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _submitForm() async {
|
void _submitForm() async {
|
||||||
bool isValid = validator.validateForm();
|
bool isValid = validator.validateForm();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user