mapper()->map('int', 'foo'); } catch (MappingError $error) { $formatter = new AggregateMessageFormatter( new LocaleMessageFormatter('fr'), new MessageMapFormatter([ 'Value {value} does not match type {expected_type}.' => 'New message: {value} / {expected_type}', ]), (new TranslationMessageFormatter())->withTranslation( 'fr', 'New message: {value} / {expected_type}', 'Nouveau message : {value} / {expected_type}', ), ); $message = $formatter->format($error->node()->messages()[0]); self::assertSame("Nouveau message : 'foo' / `int`", (string)$message); } } }