BUG: Special Chars in Business Type
This commit is contained in:
@@ -359,7 +359,8 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
requiredText: true,
|
||||
hintText: "Business Type",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
return MihValidationServices()
|
||||
.validateNoSpecialChars(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
@@ -387,7 +387,8 @@ class _ProfileBusinessAddState extends State<ProfileBusinessAdd> {
|
||||
requiredText: true,
|
||||
hintText: "Business Type",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
return MihValidationServices()
|
||||
.validateNoSpecialChars(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
|
||||
@@ -6,6 +6,17 @@ class MihValidationServices {
|
||||
return null;
|
||||
}
|
||||
|
||||
String? validateNoSpecialChars(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return "This field is required";
|
||||
}
|
||||
final specialCharRegex = RegExp(r"^[\w,'& ]+$");
|
||||
if (!specialCharRegex.hasMatch(value)) {
|
||||
return "Only , ' & _ Special characters are allowed";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? validateLength(String? value, int maxLength) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return "This field is required";
|
||||
|
||||
Reference in New Issue
Block a user