[add] New asserts
This commit is contained in:
parent
19d1f57240
commit
a5a1656518
@ -145,7 +145,11 @@ class EmployeeApplication{
|
||||
$this->asserts->betweenLength($phone, 10, 10, "The phone number must be 10 digits without special characters.");
|
||||
|
||||
$idEmployeeType = $requestData{'idEmployeeType'};
|
||||
$this->asserts->higherThanZero($idEmployeeType, 'idEmployeeType must be higher than zero.');
|
||||
|
||||
$contractType = $requestData{'contractType'};
|
||||
$this->asserts->isNotEmpty($contractType, "The contract type can't be empty.");
|
||||
$this->asserts->existInArray($contractType, $this->settings['contractTypes'], 'The contract type is not a valid one.');
|
||||
|
||||
// Encrypting the sensitive data
|
||||
$securedFirstName = $this->cryptographyService->encryptString($firstName);
|
||||
@ -421,6 +425,7 @@ class EmployeeApplication{
|
||||
|
||||
$contractType = $requestData{'contractType'};
|
||||
$this->asserts->isNotEmpty($contractType, "The contract type can't be empty.");
|
||||
$this->asserts->existInArray($contractType, $this->settings['contractTypes'], 'The contract type is not a valid one.');
|
||||
|
||||
// Encrypting the sensitive data
|
||||
$securedFirstName = $this->cryptographyService->encryptString($firstName);
|
||||
|
@ -69,5 +69,17 @@ class Asserts{
|
||||
throw new Exception($errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $string string
|
||||
* @param $array array
|
||||
* @param $errorMessage string
|
||||
* @throws Exception
|
||||
*/
|
||||
function existInArray($string, $array, $errorMessage){
|
||||
if(!in_array($string, $array)){
|
||||
throw new Exception($errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user