Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions lib/src/components/supa_email_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ class SupaEmailAuth extends StatefulWidget {
/// If unspecified, the [redirectTo] value will be used.
final String? resetPasswordRedirectTo;

/// Validator function for the password field
///
/// If null, a default validator will be used that checks if
/// the password is at least 6 characters long.
final String? Function(String?)? passwordValidator;

/// Callback for the user to complete a sign in.
final void Function(AuthResponse response) onSignInComplete;

Expand Down Expand Up @@ -209,6 +215,7 @@ class SupaEmailAuth extends StatefulWidget {
super.key,
this.redirectTo,
this.resetPasswordRedirectTo,
this.passwordValidator,
required this.onSignInComplete,
required this.onSignUpComplete,
this.onPasswordResetEmailSent,
Expand Down Expand Up @@ -313,12 +320,13 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
textInputAction: widget.metadataFields != null && !_isSigningIn
? TextInputAction.next
: TextInputAction.done,
validator: (value) {
if (value == null || value.isEmpty || value.length < 6) {
return localization.passwordLengthError;
}
return null;
},
validator: widget.passwordValidator ??
(value) {
if (value == null || value.isEmpty || value.length < 6) {
return localization.passwordLengthError;
}
return null;
},
decoration: InputDecoration(
prefixIcon: widget.prefixIconPassword,
label: Text(localization.enterPassword),
Expand Down
Loading