From f1db5ecca98adbe3a3640597cfd31ffad1646454 Mon Sep 17 00:00:00 2001 From: pbg2h21ama Date: Wed, 1 Feb 2023 11:58:55 +0100 Subject: [PATCH] =?UTF-8?q?Kommentare=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/vpr_javafx/Data.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/example/vpr_javafx/Data.java b/src/main/java/com/example/vpr_javafx/Data.java index 78b5986..7917f9b 100644 --- a/src/main/java/com/example/vpr_javafx/Data.java +++ b/src/main/java/com/example/vpr_javafx/Data.java @@ -6,9 +6,7 @@ import javafx.scene.control.Alert; import javafx.scene.control.ListView; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; -import org.w3c.dom.Text; -import java.awt.*; import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -288,12 +286,12 @@ public class Data { } /** - * The method validates the user input + * The method validates the user input for login * * @param tfPhone Phone number the user typed in * @param pfPassword Password the user typed in * @param controller Controller - * @return phoneNumberValid && passwordValid + * @return phoneNumberValid, passwordValid * @author Kevin Maier, Kevin Pfannenstiel */ public boolean validateData(TextField tfPhone, PasswordField pfPassword, HelloController controller) @@ -310,8 +308,8 @@ public class Data { String phoneNumber = tfPhone.getText(); String password = pfPassword.getText(); - Pattern phoneNumberPattern = Pattern.compile("[0-9]*"); - Pattern passwordPattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$"); + Pattern phoneNumberPattern = Pattern.compile("[0-9]*"); // Pattern that requires just numbers + Pattern passwordPattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$"); // Pattern that requires minimum eight characters, at least one letter and one number if (password.isEmpty() || phoneNumber.isEmpty()) { @@ -349,12 +347,20 @@ public class Data { return phoneNumberValid && passwordValid; } + /** + * The method validates the user input for registration * - * @param tfPhone - * @param pfPassword - * @param controller - * @author Kevin Maier + * @param tfName The name the user typed in + * @param tfPhone The phone number the user typed in + * @param pfPassword The password the user typed in + * @param tfStreet The street name the user typed in + * @param tfHouseNumber The house number the user typed in + * @param tfPostalCode The postal code the user typed in + * @param tfCity The city the user typed in + * @param tfChild The child the user typed in + * @param controller Controller + * @return phoneNumberValid, passwordValid, postalCodeValid */ public boolean validateRegistration(TextField tfName, TextField tfPhone, PasswordField pfPassword, TextField tfStreet, TextField tfHouseNumber, TextField tfPostalCode, TextField tfCity, TextField tfChild, HelloController controller) { @@ -373,9 +379,9 @@ public class Data { String password = pfPassword.getText(); String postalCode = tfPostalCode.getText(); - Pattern phoneNumberPattern = Pattern.compile("[0-9]*"); - Pattern passwordPattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$"); - Pattern postalCodePattern = Pattern.compile("[0-9]{5}"); + Pattern phoneNumberPattern = Pattern.compile("[0-9]*"); // Pattern that requires just numbers + Pattern passwordPattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$"); // Pattern that requires minimum eight characters, at least one letter and one number + Pattern postalCodePattern = Pattern.compile("[0-9]{5}"); // Pattern that requires 5 numbers if (tfName.getText().isEmpty() || tfPhone.getText().isEmpty() || pfPassword.getText().isEmpty() || tfStreet.getText().isEmpty() || tfHouseNumber.getText().isEmpty() || tfPostalCode.getText().isEmpty() || tfCity.getText().isEmpty() || tfChild.getText().isEmpty()) {