Browse Source

refactoring: removed redundant code from the function isValidPhoneNumber() and the constant from the function and added it to the header file.

remotes/origin/feature/employees-infos-access
fdai7207 2 years ago
parent
commit
fc6033da00
  1. 10
      src/createEmployeeAccount.c
  2. 1
      src/createEmployeeAccount.h

10
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)

1
src/createEmployeeAccount.h

@ -10,6 +10,7 @@
#define minPasswordLength 5
#define minimumNameLength 4
#define maxLength 21
#define validNumberLength 14
struct employeesInformations
{

Loading…
Cancel
Save