password method

FormFieldValidator<String> password (
  1. {String errorMessage,
  2. int minLength: 4,
  3. int maxLength,
  4. bool shouldContainNumber: false,
  5. bool shouldContainSpecialChars: false,
  6. bool shouldContainCapitalLetter: false,
  7. Function reason,
  8. String isNumberNotPresent(
      ),
    1. String isSpecialCharsNotPresent(
        ),
      1. String isCapitalLetterNotPresent(
          )}
        )

        Implementation

        static FormFieldValidator<String> password({
          String errorMessage,
          int minLength = 4,
          int maxLength,
          bool shouldContainNumber = false,
          bool shouldContainSpecialChars = false,
          bool shouldContainCapitalLetter = false,
          Function reason,
          String Function() isNumberNotPresent,
          String Function() isSpecialCharsNotPresent,
          String Function() isCapitalLetterNotPresent,
        }) {
          return (fieldValue) {
            var mainError = errorMessage;
        
            if (Validator.isPassword(
              fieldValue,
              minLength: minLength,
              maxLength: maxLength,
              shouldContainSpecialChars: shouldContainSpecialChars,
              shouldContainCapitalLetter: shouldContainCapitalLetter,
              shouldContainNumber: shouldContainNumber,
              isNumberPresent: (present) {
                if (!present) mainError = isNumberNotPresent();
              },
              isCapitalLetterPresent: (present) {
                if (!present) mainError = isCapitalLetterNotPresent();
              },
              isSpecialCharsPresent: (present) {
                if (!present) mainError = isSpecialCharsNotPresent();
              },
            )) {
              return null;
            } else {
              return mainError ?? "Password must match the required format";
            }
          };
        }