validateString static method
bool
validateString(
- String string, {
- int minLength = 8,
- int maxLength = 20,
- bool firstCapital = false,
- bool firstDigit = false,
- bool includeDigit = false,
- bool includeAlphabet = false,
- bool includeSpecialCharacter = false,
- List<
String> ? includeCharacters, - List<
String> ? ignoreCharacters, - int minAlphabet = 5,
- int maxAlphabet = 20,
- int minDigit = 0,
- int maxDigit = 20,
Implementation
static bool validateString(String string, {
int minLength = 8,
int maxLength = 20,
bool firstCapital = false,
bool firstDigit = false,
bool includeDigit = false,
bool includeAlphabet = false,
bool includeSpecialCharacter = false,
List<String>? includeCharacters,
List<String>? ignoreCharacters,
int minAlphabet = 5,
int maxAlphabet = 20,
int minDigit = 0,
int maxDigit = 20,
}) {
if (string.length < minLength) {
return false;
}
if (string.length > maxLength) {
return false;
}
if (firstCapital && !isFirstCapital(string)) {
return false;
}
if (firstDigit && !isFirstLetter(string)) {
return false;
}
if (includeAlphabet && !isAlphabetIncluded(string)) {
return false;
}
if (includeDigit && !isDigitIncluded(string)) {
return false;
}
if (includeSpecialCharacter && !isSpecialCharacterIncluded(string)) {
return false;
}
if (!isIncludedCharactersPresent(string, includeCharacters)) {
return false;
}
if (isIgnoreCharactersPresent(string, ignoreCharacters)) {
return false;
}
if (!checkMaxAlphabet(string, maxAlphabet)) {
return false;
}
if (!checkMinAlphabet(string, minAlphabet)) {
return false;
}
if (!checkMaxDigit(string, maxAlphabet)) {
return false;
}
if (!checkMinDigit(string, minAlphabet)) {
return false;
}
return true;
}