@@ -29,13 +29,13 @@ final class FormErrorIteratorToConstraintViolationList
2929 /**
3030 * @param FormErrorIterator<FormError> $errors
3131 */
32- public static function transform (FormErrorIterator $ errors ): ConstraintViolationListInterface
32+ public static function transform (FormErrorIterator $ errors, bool $ removeSensitiveData = false ): ConstraintViolationListInterface
3333 {
3434 $ form = $ errors ->getForm ();
3535 $ list = new ConstraintViolationList ();
3636
3737 foreach ($ errors as $ error ) {
38- $ violation = static ::buildViolation ($ error , $ form );
38+ $ violation = static ::buildViolation ($ error , $ form, $ removeSensitiveData );
3939
4040 if (null === $ violation ) {
4141 continue ;
@@ -47,7 +47,7 @@ public static function transform(FormErrorIterator $errors): ConstraintViolation
4747 return $ list ;
4848 }
4949
50- private static function buildViolation (FormError $ error , FormInterface $ form ): ?ConstraintViolationInterface
50+ private static function buildViolation (FormError $ error , FormInterface $ form, bool $ removeSensitiveData ): ?ConstraintViolationInterface
5151 {
5252 $ cause = $ error ->getCause ();
5353
@@ -57,8 +57,8 @@ private static function buildViolation(FormError $error, FormInterface $form): ?
5757
5858 return new ConstraintViolation (
5959 $ cause ->getMessage (),
60- $ cause ->getMessageTemplate (),
61- $ cause ->getParameters (),
60+ $ removeSensitiveData ? null : $ cause ->getMessageTemplate (),
61+ $ removeSensitiveData ? [] : $ cause ->getParameters (),
6262 $ cause ->getRoot (),
6363 self ::buildName ($ error ->getOrigin () ?? $ form ),
6464 $ cause ->getInvalidValue (),
0 commit comments