Ajout d'autres validations
continuous-integration/drone/push Build is passing Details

interestingProfiles
Johan LACHENAL 2 years ago
parent 2872f25859
commit efae1c1720

@ -129,4 +129,10 @@ class Validate
}
return true;
}
public static function answer(string $answer): bool
{
global $answerMaxLength;
return (strlen($answer) <= $answerMaxLength);
}
}

@ -50,4 +50,5 @@ $titleMaxLength=50;
$typeMaxLength=50;
$responseMaxLength=200;
$categoryMaxLenght=150;
$answerMaxLength=1500;

@ -44,9 +44,9 @@ class ModelCandidate
foreach ($answersAndCategories as $answerAndCategory) {
$exploded = explode("||",$answerAndCategory);
if( count($exploded) == 3 ){
$questionsId[] = $exploded[0];
$answer[] = $exploded[1];
$categs = $exploded[2];
$questionsId[] = Clean::int($exploded[0]);
$answer[] = Clean::simpleString($exploded[1]);
$categs = Clean::simpleStringArray($exploded[2]);
$categs = explode("_", $categs);
array_pop($categs);
$category[] = $categs;
@ -58,6 +58,9 @@ class ModelCandidate
}
}
try {
if(!Validate::answer($answer) || !Validate::category($category)){
throw new Exception("Les réponses ne sont pas valides");
}
$res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getForm');
$form = json_decode($res->getBody());
$title = $form[0]["title"];

Loading…
Cancel
Save