Skip to content

Commit

Permalink
improve password validation handling (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmohsin7 authored Dec 19, 2024
1 parent b6090d3 commit 51962fe
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/screens/authentification/create_password_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class _CreatePasswordPageState extends State<CreatePasswordPage> {
if (text.isEmpty ||
text2.isEmpty ||
!_formKey.currentState.validate() ||
controller1.text != controller2.text) {
controller1.text != controller2.text ||
controller1.text.length < 12 ||
controller2.text.length < 12) {
setState(() {
isValidPassword = false;
});
Expand All @@ -49,12 +51,16 @@ class _CreatePasswordPageState extends State<CreatePasswordPage> {
}

bool _validateInputs() {
// Only validate if the user has entered atleast 3 characters.
if (controller1.text.length < 3) {
return false;
}
if (_formKey.currentState.validate()) {
// If all data are correct then save data to out variables
// If all data are correct then save data to out variables
_formKey.currentState.save();
return true;
} else {
// If all data are not valid then start auto validation.
// If all data are not valid then start auto validation.
setState(() {
_autoValidate = true;
});
Expand Down Expand Up @@ -90,6 +96,9 @@ class _CreatePasswordPageState extends State<CreatePasswordPage> {
_fieldFocusChange(context, _focus1, _focus2);
_validateInputs();
},
onChanged: (value) {
_validateInputs();
},
textInputAction: TextInputAction.next,
autocorrect: false,
enableInteractiveSelection: true,
Expand Down

0 comments on commit 51962fe

Please sign in to comment.