Kommentare ergänzt

This commit is contained in:
Kevin Maier 2023-02-01 12:27:20 +01:00
parent f664299fae
commit 85a599cda5

View File

@ -281,10 +281,13 @@ public class Data {
} }
/** /**
* The method validates the user input * The method validates the user input for login
* *
* @return boolean inputValid * @param tfPhone Phone number the user typed in
* @author Kevin Maier, Kevin Pfannenstiel * @param pfPassword Password the user typed in
* @param controller Controller
* @return phoneNumberValid, passwordValid
* @author Kevin Maier, Kevin Pfannenstiel
*/ */
public boolean validateData(TextField tfPhone, PasswordField pfPassword, HelloController controller) public boolean validateData(TextField tfPhone, PasswordField pfPassword, HelloController controller)
{ {
@ -298,8 +301,8 @@ public class Data {
String phoneNumber = tfPhone.getText(); String phoneNumber = tfPhone.getText();
String password = pfPassword.getText(); String password = pfPassword.getText();
Pattern phoneNumberPattern = Pattern.compile("[0-9]*"); Pattern phoneNumberPattern = Pattern.compile("[0-9]*"); // Pattern that requires numbers
Pattern passwordPattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$"); 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()) if (password.isEmpty() || phoneNumber.isEmpty())
{ {
@ -395,11 +398,18 @@ public class Data {
} }
/** /**
* The method validates the user input for registration
* *
* @param tfPhone * @param tfName The name the user typed in
* @param pfPassword * @param tfPhone The phone number the user typed in
* @param controller * @param pfPassword The password the user typed in
* @author Kevin Maier * @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) public boolean validateRegistration(TextField tfName, TextField tfPhone, PasswordField pfPassword, TextField tfStreet, TextField tfHouseNumber, TextField tfPostalCode, TextField tfCity, TextField tfChild, HelloController controller)
{ {
@ -418,9 +428,9 @@ public class Data {
String password = pfPassword.getText(); String password = pfPassword.getText();
String postalCode = tfPostalCode.getText(); String postalCode = tfPostalCode.getText();
Pattern phoneNumberPattern = Pattern.compile("[0-9]*"); Pattern phoneNumberPattern = Pattern.compile("[0-9]*"); // Pattern that requires numbers
Pattern passwordPattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$"); 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 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()) 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())
{ {