Redirige les requêtes invalides vers la vue d'erreur
This commit is contained in:
17
src/Silex/Validation/CommentValidation.php
Normal file
17
src/Silex/Validation/CommentValidation.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user