mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 15:50:03 +01:00
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>
36 lines
817 B
PHP
36 lines
817 B
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation;
|
|
|
|
use Respect\Validation\Exceptions\ValidationException;
|
|
|
|
interface Validatable
|
|
{
|
|
public const TEMPLATE_STANDARD = 'standard';
|
|
|
|
public function assert(mixed $input): void;
|
|
|
|
public function check(mixed $input): void;
|
|
|
|
public function getName(): ?string;
|
|
|
|
/**
|
|
* @param mixed[] $extraParameters
|
|
*/
|
|
public function reportError(mixed $input, array $extraParameters = []): ValidationException;
|
|
|
|
public function setName(string $name): Validatable;
|
|
|
|
public function setTemplate(string $template): Validatable;
|
|
|
|
public function getTemplate(mixed $input): string;
|
|
|
|
public function validate(mixed $input): bool;
|
|
}
|