respect-validation/library/Message/Formatter.php
Henrique Moody 82cb05b197
Handle siblings when creating messages
The way we display messages could have been better, and it took me a
while to realise that to make it better, I would need to handle the
siblings of a result before deciding whether we should render it.

Another issue was that rules like Key and Property had to create a
"dumb" parent just so we would display the messages correctly, and in
some cases, that wasn't even enough.

This commit introduces quite a few changes to how the library works,
making the messages much more straightforward.
2024-12-13 02:34:27 +01:00

38 lines
820 B
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Message;
use Respect\Validation\Result;
interface Formatter
{
/**
* @param array<string, mixed> $templates
*/
public function main(Result $result, array $templates, Translator $translator): string;
/**
* @param array<string, mixed> $templates
*/
public function full(
Result $result,
array $templates,
Translator $translator,
int $depth = 0,
Result ...$siblings
): string;
/**
* @param array<string, mixed> $templates
*
* @return array<string, mixed>
*/
public function array(Result $result, array $templates, Translator $translator): array;
}