Browse Source

refactoring: removed redundancy in the isValidAdress() function.

remotes/origin/backup-for-employees-infos-access
fdai7207 2 years ago
parent
commit
97fd90edae
  1. 15
      src/createEmployeeAccount.c
  2. 2
      src/createEmployeeAccount.h

15
src/createEmployeeAccount.c

@ -82,18 +82,15 @@ bool isValidPhoneNumber(char *phoneNumber)
bool isValidAdress(char *street,char* city,int houseNumber,int postalCode)
{
int lengthMax = 20;
int LengthMin = 3;
bool validStreet = true;
bool validHouseNumber = true;
bool validCity = true;
bool validpostalCode = true;
if(strlen(street)>lengthMax || strlen(street)<LengthMin)
if(strlen(street)>maximalAdressLength || strlen(street)<minimalAdressLength)
{
validStreet = false;
}
if(strlen(city)>lengthMax || strlen(city)<LengthMin)
if(strlen(city)>maximalAdressLength || strlen(city)<minimalAdressLength)
{
validCity = false;
}
@ -105,13 +102,7 @@ bool isValidAdress(char *street,char* city,int houseNumber,int postalCode)
{
validpostalCode = false;
}
if(validStreet==true && validCity==true && validHouseNumber==true && validpostalCode==true)
{
return true;
}
{
return false;
}
return (validStreet && validCity && validHouseNumber && validpostalCode);
}
int StringLengthCounter(char* string)

2
src/createEmployeeAccount.h

@ -11,6 +11,8 @@
#define minimumNameLength 4
#define maxLength 21
#define validNumberLength 14
#define maximalAdressLength 20
#define minimalAdressLength 3
struct employeesInformations
{

Loading…
Cancel
Save