From fc6033da000058972f55b42b450098c2b6381349 Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Wed, 8 Feb 2023 02:23:32 +0100 Subject: [PATCH] refactoring: removed redundant code from the function isValidPhoneNumber() and the constant from the function and added it to the header file. --- src/createEmployeeAccount.c | 10 ++-------- src/createEmployeeAccount.h | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index 308b390..9550f40 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -69,21 +69,15 @@ bool isValidName(char* name,const int minimalLength) bool isValidPhoneNumber(char *phoneNumber) { - const int validNumberLength = 14; int numberLength = strlen(phoneNumber); - if(numberLength != validNumberLength) - { - return false; - } - - if(phoneNumber[0]!='+' || phoneNumber[1]!='4' || phoneNumber[2]!='9') + /*this function checks if the 3 first characters a german suffix are*/ + if(phoneNumber[0]!='+' || phoneNumber[1]!='4' || phoneNumber[2]!='9' || numberLength != validNumberLength) { return false; } return true; - } int StringLengthCounter(char* string) diff --git a/src/createEmployeeAccount.h b/src/createEmployeeAccount.h index 03cd582..9c67108 100644 --- a/src/createEmployeeAccount.h +++ b/src/createEmployeeAccount.h @@ -10,6 +10,7 @@ #define minPasswordLength 5 #define minimumNameLength 4 #define maxLength 21 +#define validNumberLength 14 struct employeesInformations {