実際、フォームの検証は「 Validator Component 」という名前のコンポーネントに基づいています。
テンプレートにフォームを表示する必要がない場合は、専用サービスを使用することができます。 APIと同様。次のように、データを同じ方法で検証することができます:
例えば、 symfony docに基づいています:
$validator = $this->get('validator');
$errors = $validator->validate($author);
if (count($errors) > 0) {
/*
* Uses a __toString method on the $errors variable which is a
* ConstraintViolationList object. This gives us a nice string
* for debugging.
*/
$errorsString = (string) $errors;
}