From 9cad95ce803813f66ded574f7ccc4e66a4cc8627 Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Fri, 10 Feb 2023 01:57:41 +0100 Subject: [PATCH] implement the function isValidAdress(). --- src/createEmployeeAccount.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index 9550f40..c7fac7c 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -80,6 +80,41 @@ bool isValidPhoneNumber(char *phoneNumber) return true; } +bool isValidAdress(char *street,int houseNumber,char* city,int postalCode) +{ + int maximalLength = 20; + int minimalLength = 3; + bool validStreet = true; + bool validHouseNumber = true; + bool validCity = true; + bool validpostalCode = true; + if(strlen(street)>20 || strlen(street)<3) + { + validStreet = false; + } + + if(strlen(city)>20 || strlen(city)<3) + { + validCity = false; + } + if(houseNumber<1 || houseNumber > 999) + { + validHouseNumber = false; + } + if(postalCode<1000 || postalCode > 99000) + { + validpostalCode = false; + } + if(validStreet && validCity && validHouseNumber && validpostalCode) + { + return true; + } + else + { + return false; + } +} + int StringLengthCounter(char* string) { int characterCounter = 0;