|
|
@ -4,7 +4,7 @@ namespace Silex\Validation;
|
|
|
|
|
|
|
|
|
|
|
|
final class CommentValidation
|
|
|
|
final class CommentValidation
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public static function isValidComment(array $post, bool $requiresName, array &$errors): bool
|
|
|
|
public static function isValidComment(array &$post, bool $requiresName, array &$errors): bool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ($requiresName) {
|
|
|
|
if ($requiresName) {
|
|
|
|
UserValidation::isValidName($post, $errors, 'name');
|
|
|
|
UserValidation::isValidName($post, $errors, 'name');
|
|
|
@ -12,6 +12,7 @@ final class CommentValidation
|
|
|
|
if (empty($post['content'])) {
|
|
|
|
if (empty($post['content'])) {
|
|
|
|
$errors[] = 'Empty message';
|
|
|
|
$errors[] = 'Empty message';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$post['content'] = htmlspecialchars($post['content']);
|
|
|
|
return empty($errors);
|
|
|
|
return empty($errors);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|