Move template definitions to the rules

It's easier to identify the reason for choosing a specific message in
the rule than in the exception. The same goes for the key we use to
determine the templates.

This change will simplify the `ValidationException` because it will
already receive the template it needs to use. As a consequence, the
`Factory` also becomes more straightforward.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2024-01-29 17:29:01 +01:00
commit dd896bb12d
No known key found for this signature in database
GPG key ID: 221E9281655813A6
181 changed files with 1042 additions and 680 deletions

View file

@ -9,6 +9,8 @@ declare(strict_types=1);
namespace Respect\Validation\Exceptions;
use Respect\Validation\Validatable;
final class LanguageCodeException extends ValidationException
{
/**
@ -16,10 +18,10 @@ final class LanguageCodeException extends ValidationException
*/
protected array $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} must be a valid ISO 639 {{set}} language code',
Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid ISO 639 {{set}} language code',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} must not be a valid ISO 639 {{set}} language code',
Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid ISO 639 {{set}} language code',
],
];
}