@@ -323,7 +323,7 @@ class FormBuilderValidators {
323
323
String ? errorText,
324
324
}) =>
325
325
(valueCandidate) => true == valueCandidate? .isNotEmpty &&
326
- ! isCreditCardExpirationDate (valueCandidate! ) ||
326
+ ! isCreditCardExpirationDate (valueCandidate! ) ||
327
327
! isNotExpiredCreditCardDate (valueCandidate! )
328
328
? errorText ??
329
329
FormBuilderLocalizations .current.creditCardExpiredErrorText
@@ -559,4 +559,37 @@ class FormBuilderValidators {
559
559
? null
560
560
: errorText ??
561
561
FormBuilderLocalizations .current.containsNumberErrorText (atLeast);
562
+
563
+ /// [FormFieldValidator] that requires the field's value to be a valid password.
564
+ /// * [minLength] is the minimum length of the password. By default `8`
565
+ /// * [maxLength] is the maximum length of the password. By default `32`
566
+ /// * [uppercase] is the minimum amount of uppercase characters. By default `1`
567
+ /// * [lowercase] is the minimum amount of lowercase characters. By default `1`
568
+ /// * [number] is the minimum amount of numeric characters. By default `1`
569
+ /// * [specialChar] is the minimum amount of special characters. By default `1`
570
+ /// * [errorText] is the error message to display when the password is invalid
571
+ static FormFieldValidator <String > password ({
572
+ int minLength = 8 ,
573
+ int maxLength = 32 ,
574
+ int uppercase = 1 ,
575
+ int lowercase = 1 ,
576
+ int number = 1 ,
577
+ int specialChar = 1 ,
578
+ String ? errorText,
579
+ }) {
580
+ return FormBuilderValidators .compose <String >(
581
+ [
582
+ FormBuilderValidators .minLength (minLength, errorText: errorText),
583
+ FormBuilderValidators .maxLength (maxLength, errorText: errorText),
584
+ FormBuilderValidators .hasUppercaseChars (
585
+ atLeast: uppercase, errorText: errorText),
586
+ FormBuilderValidators .hasLowercaseChars (
587
+ atLeast: lowercase, errorText: errorText),
588
+ FormBuilderValidators .hasNumericChars (
589
+ atLeast: number, errorText: errorText),
590
+ FormBuilderValidators .hasSpecialChars (
591
+ atLeast: specialChar, errorText: errorText),
592
+ ],
593
+ );
594
+ }
562
595
}
0 commit comments