Redirige les requêtes invalides vers la vue d'erreur

This commit is contained in:
2022-12-11 12:34:49 +01:00
parent 82254c2f79
commit 5ca17e7e59
9 changed files with 68 additions and 51 deletions

View File

@@ -0,0 +1,17 @@
<?php
namespace Silex\Validation;
final class CommentValidation
{
public static function isValidComment(array $post, bool $requiresName, array &$errors): bool
{
if ($requiresName) {
UserValidation::isValidName($post, $errors, 'name');
}
if (empty($post['content'])) {
$errors[] = 'Empty message';
}
return empty($errors);
}
}