Skip to content

Commit

Permalink
Update Request.php
Browse files Browse the repository at this point in the history
  • Loading branch information
secure73 authored May 9, 2024
1 parent abfe285 commit 81ab6f8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,16 @@ public function definePostSchema(array $toValidatePost): bool
(!substr($validation_key, 0, 1) === '?') ? $requires[$validation_key] = $validationString : $optionals[ltrim($validation_key, '?')] = $validationString; // Use ternary operator
$all[$validation_key] = $validationString;
}
foreach($this->post as $postName => $postValue) { //if there is any post other than defined schma, instanlty breake the process and return false.
if(!array_key_exists($postName ,$all)) {

foreach($this->post as $postName => $postValue) { //if there is any post other than defined schma, instanlty breake the process and return false.
if(!array_key_exists($postName ,$all)) {
$errors[$postName] = "unwanted post $postName";
unset($this->post[$postName]);
}
}
if (count($errors) > 0) { //if unwanted post exists , stop process and return false
foreach ($errors as $error) {
$this->error .= $error . ', '; // Combine errors into a single string
}
return false;
}
Expand Down

0 comments on commit 81ab6f8

Please sign in to comment.