From 7217f24927201be528760105cc64a6a046a22606 Mon Sep 17 00:00:00 2001 From: gokakyu Date: Wed, 27 Mar 2024 15:45:23 +0100 Subject: [PATCH] [Validation] Check validation errors by using the OOP way --- validation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validation.rst b/validation.rst index 3f9b16785d1..f2544903a98 100644 --- a/validation.rst +++ b/validation.rst @@ -144,7 +144,7 @@ returned. Take this simple example from inside a controller:: $errors = $validator->validate($author); - if (count($errors) > 0) { + if ($errors->count() > 0) { /* * Uses a __toString method on the $errors variable which is a * ConstraintViolationList object. This gives us a nice string @@ -178,7 +178,7 @@ will appear. You could also pass the collection of errors into a template:: - if (count($errors) > 0) { + if ($errors->count() > 0) { return $this->render('author/validation.html.twig', [ 'errors' => $errors, ]);