add length validation service
This commit is contained in:
parent
31253b7511
commit
d392b97e73
1 changed files with 10 additions and 0 deletions
|
|
@ -6,6 +6,16 @@ class MihValidationServices {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? validateLength(String? value, int maxLength) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return "This field is required";
|
||||||
|
}
|
||||||
|
if (value.length > maxLength) {
|
||||||
|
return "Length must not exceed $maxLength characters";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String? validateEmail(String? email) {
|
String? validateEmail(String? email) {
|
||||||
if (email == null || email.isEmpty) {
|
if (email == null || email.isEmpty) {
|
||||||
return "Email is required";
|
return "Email is required";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue