diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6f10773f..01fce1897 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,6 @@ Before writing anything, feature or bug fix: A common validator (rule) on Respect\Validation is composed of three classes: * `library/Rules/YourRuleName.php`: the rule itself - * `library/Exceptions/YourRuleNameException.php`: the exception thrown by the rule * `tests/unit/Rules/YourRuleNameTest.php`: tests for the rule The classes are pretty straightforward. In the sample below, we're going to @@ -62,6 +61,12 @@ declare(strict_types=1); namespace Respect\Validation\Rules; +use Respect\Validation\Attributes\Template; + +#[Template( + '{{name}} must be a Hello World', + '{{name}} must not be a Hello World', +)] final class HelloWorld extends AbstractRule { public function validate(mixed $input): bool @@ -71,41 +76,6 @@ final class HelloWorld extends AbstractRule } ``` -### Creating the rule exception - -Just that and we're done with the rule code. The Exception requires you to -declare messages used by `assert()` and `check()`. Messages are declared in -affirmative and negative moods, so if anyone calls `v::not(v::helloWorld())` the -library will show the appropriate message. - -```php - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -final class HelloWorldException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - self::STANDARD => '{{name}} must be a Hello World', - ], - self::MODE_NEGATIVE => [ - self::STANDARD => '{{name}} must not be a Hello World', - ] - ]; -} -``` - ### Creating unit tests Finally, we need to test if everything is running smooth. We have `RuleTestCase` @@ -173,7 +143,7 @@ for it other than what is covered by `RuleTestCase`. ### Helping us a little bit more -You rule will be accepted only with these 3 files (rule, exception and unit test), +You rule will be accepted only with these 3 files (rule and unit test), but if you really want to help us, you can follow the example of [ArrayType][] by: - Adding your new rule on the `Validator`'s class docblock; diff --git a/docs/custom-rules.md b/docs/custom-rules.md index 12d17fb81..ffbd8abe4 100644 --- a/docs/custom-rules.md +++ b/docs/custom-rules.md @@ -11,55 +11,23 @@ validate method will be executed. Here's how the class should look: namespace My\Validation\Rules; use Respect\Validation\Rules\AbstractRule; +use Respect\Validation\Attributes\Template; +#[Template( + '{{name}} is something', + '{{name}} is not something', +)] final class Something extends AbstractRule { - public function validate($input): bool + public function validate(mixed $input): bool { // Do something here with the $input and return a boolean value } } ``` -Each rule must have an Exception to go with it. Exceptions should be named -with the name of the rule followed by the word Exception. The process of creating -an Exception is similar to creating a rule but there are no methods in the -Exception class. Instead, you create one static property that includes an -array with the information below: - -```php -namespace My\Validation\Exceptions; - -use Respect\Validation\Exceptions\ValidationException; - -final class SomethingException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - self::STANDARD => 'Validation message if Something fails validation.', - ], - self::MODE_NEGATIVE => [ - self::STANDARD => 'Validation message if the negative of Something is called and fails validation.', - ], - ]; -} -``` - -So in the end, the folder structure for your Rules and Exceptions should look -something like the structure below. Note that the folders (and namespaces) are -plural but the actual Rules and Exceptions are singular. - -``` -My - +-- Validation - +-- Exceptions - +-- SomethingException.php - +-- Rules - +-- Something.php -``` +The `'{{name}} is not something` message would be used then you call the rule +with the `not()`. All classes in Validation are created by the `Factory` class. If you want Validation to execute your rule (or rules) in the chain, you must overwrite the @@ -69,7 +37,6 @@ default `Factory`. Factory::setDefaultInstance( (new Factory()) ->withRuleNamespace('My\\Validation\\Rules') - ->withExceptionNamespace('My\\Validation\\Exceptions') ); v::something(); // Try to load "My\Validation\Rules\Something" if any ``` diff --git a/library/Attributes/ExceptionClass.php b/library/Attributes/ExceptionClass.php new file mode 100644 index 000000000..4fdab5a46 --- /dev/null +++ b/library/Attributes/ExceptionClass.php @@ -0,0 +1,25 @@ + + * SPDX-License-Identifier: MIT + */ + +declare(strict_types=1); + +namespace Respect\Validation\Attributes; + +use Attribute; +use Respect\Validation\Exceptions\ValidationException; + +#[Attribute(Attribute::TARGET_CLASS)] +final class ExceptionClass +{ + /** + * @param class-string $class + */ + public function __construct( + public readonly string $class + ) { + } +} diff --git a/library/Attributes/Template.php b/library/Attributes/Template.php new file mode 100644 index 000000000..5469a2fa5 --- /dev/null +++ b/library/Attributes/Template.php @@ -0,0 +1,24 @@ + + * SPDX-License-Identifier: MIT + */ + +declare(strict_types=1); + +namespace Respect\Validation\Attributes; + +use Attribute; +use Respect\Validation\Validatable; + +#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)] +final class Template +{ + public function __construct( + public readonly string $default, + public readonly string $negative, + public readonly string $id = Validatable::TEMPLATE_STANDARD, + ) { + } +} diff --git a/library/Exceptions/AllOfException.php b/library/Exceptions/AllOfException.php deleted file mode 100644 index a0140c1c5..000000000 --- a/library/Exceptions/AllOfException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -class AllOfException extends GroupedValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - self::NONE => 'All of the required rules must pass for {{name}}', - self::SOME => 'These rules must pass for {{name}}', - ], - self::MODE_NEGATIVE => [ - self::NONE => 'None of these rules must pass for {{name}}', - self::SOME => 'These rules must not pass for {{name}}', - ], - ]; -} diff --git a/library/Exceptions/AlnumException.php b/library/Exceptions/AlnumException.php deleted file mode 100644 index e1b4aa44d..000000000 --- a/library/Exceptions/AlnumException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\AbstractFilterRule as Filter; -use Respect\Validation\Validatable; - -final class AlnumException extends FilteredValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain only letters (a-z) and digits (0-9)', - Filter::TEMPLATE_EXTRA => '{{name}} must contain only letters (a-z), digits (0-9) and {{additionalChars}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain letters (a-z) or digits (0-9)', - Filter::TEMPLATE_EXTRA => '{{name}} must not contain letters (a-z), digits (0-9) or {{additionalChars}}', - ], - ]; -} diff --git a/library/Exceptions/AlphaException.php b/library/Exceptions/AlphaException.php deleted file mode 100644 index 745cc9fe6..000000000 --- a/library/Exceptions/AlphaException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\AbstractFilterRule; -use Respect\Validation\Validatable; - -final class AlphaException extends FilteredValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain only letters (a-z)', - AbstractFilterRule::TEMPLATE_EXTRA => '{{name}} must contain only letters (a-z) and {{additionalChars}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain letters (a-z)', - AbstractFilterRule::TEMPLATE_EXTRA => '{{name}} must not contain letters (a-z) or {{additionalChars}}', - ], - ]; -} diff --git a/library/Exceptions/AlwaysInvalidException.php b/library/Exceptions/AlwaysInvalidException.php deleted file mode 100644 index 0cf0aef46..000000000 --- a/library/Exceptions/AlwaysInvalidException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class AlwaysInvalidException extends ValidationException -{ - public const SIMPLE = 'simple'; - - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} is always invalid', - self::SIMPLE => '{{name}} is not valid', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} is always valid', - self::SIMPLE => '{{name}} is valid', - ], - ]; -} diff --git a/library/Exceptions/AlwaysValidException.php b/library/Exceptions/AlwaysValidException.php deleted file mode 100644 index 1a404ca6f..000000000 --- a/library/Exceptions/AlwaysValidException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class AlwaysValidException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} is always valid', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} is always invalid', - ], - ]; -} diff --git a/library/Exceptions/AnyOfException.php b/library/Exceptions/AnyOfException.php deleted file mode 100644 index 1a12899ba..000000000 --- a/library/Exceptions/AnyOfException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class AnyOfException extends NestedValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'At least one of these rules must pass for {{name}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'At least one of these rules must not pass for {{name}}', - ], - ]; -} diff --git a/library/Exceptions/ArrayTypeException.php b/library/Exceptions/ArrayTypeException.php deleted file mode 100644 index 05c1b7c09..000000000 --- a/library/Exceptions/ArrayTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ArrayTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be of type array', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be of type array', - ], - ]; -} diff --git a/library/Exceptions/ArrayValException.php b/library/Exceptions/ArrayValException.php deleted file mode 100644 index c5cf5d279..000000000 --- a/library/Exceptions/ArrayValException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ArrayValException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be an array value', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an array value', - ], - ]; -} diff --git a/library/Exceptions/Base64Exception.php b/library/Exceptions/Base64Exception.php deleted file mode 100644 index 9bebaa268..000000000 --- a/library/Exceptions/Base64Exception.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class Base64Exception extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be Base64-encoded', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be Base64-encoded', - ], - ]; -} diff --git a/library/Exceptions/BaseException.php b/library/Exceptions/BaseException.php deleted file mode 100644 index 13e8d5a26..000000000 --- a/library/Exceptions/BaseException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class BaseException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a number in the base {{base}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a number in the base {{base}}', - ], - ]; -} diff --git a/library/Exceptions/BetweenException.php b/library/Exceptions/BetweenException.php deleted file mode 100644 index 6ef6ba02d..000000000 --- a/library/Exceptions/BetweenException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class BetweenException extends NestedValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be between {{minValue}} and {{maxValue}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be between {{minValue}} and {{maxValue}}', - ], - ]; -} diff --git a/library/Exceptions/BoolTypeException.php b/library/Exceptions/BoolTypeException.php deleted file mode 100644 index 8d8882948..000000000 --- a/library/Exceptions/BoolTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class BoolTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be of type boolean', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be of type boolean', - ], - ]; -} diff --git a/library/Exceptions/BoolValException.php b/library/Exceptions/BoolValException.php deleted file mode 100644 index 68aa85f55..000000000 --- a/library/Exceptions/BoolValException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class BoolValException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a boolean value', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a boolean value', - ], - ]; -} diff --git a/library/Exceptions/BsnException.php b/library/Exceptions/BsnException.php deleted file mode 100644 index a860abbae..000000000 --- a/library/Exceptions/BsnException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class BsnException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a BSN', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a BSN', - ], - ]; -} diff --git a/library/Exceptions/CallException.php b/library/Exceptions/CallException.php deleted file mode 100644 index b74510c4f..000000000 --- a/library/Exceptions/CallException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class CallException extends NestedValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{input}} must be valid when executed with {{callable}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{input}} must not be valid when executed with {{callable}}', - ], - ]; -} diff --git a/library/Exceptions/CallableTypeException.php b/library/Exceptions/CallableTypeException.php deleted file mode 100644 index 1f4afa715..000000000 --- a/library/Exceptions/CallableTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class CallableTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be callable', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be callable', - ], - ]; -} diff --git a/library/Exceptions/CharsetException.php b/library/Exceptions/CharsetException.php deleted file mode 100644 index 5e4ecc6c4..000000000 --- a/library/Exceptions/CharsetException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class CharsetException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be in the {{charset}} charset', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be in the {{charset}} charset', - ], - ]; -} diff --git a/library/Exceptions/CnhException.php b/library/Exceptions/CnhException.php deleted file mode 100644 index 03b98c449..000000000 --- a/library/Exceptions/CnhException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class CnhException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid CNH number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid CNH number', - ], - ]; -} diff --git a/library/Exceptions/CnpjException.php b/library/Exceptions/CnpjException.php deleted file mode 100644 index 2037aaa18..000000000 --- a/library/Exceptions/CnpjException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class CnpjException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid CNPJ number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid CNPJ number', - ], - ]; -} diff --git a/library/Exceptions/ConsonantException.php b/library/Exceptions/ConsonantException.php deleted file mode 100644 index 99a736c8e..000000000 --- a/library/Exceptions/ConsonantException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\AbstractFilterRule; -use Respect\Validation\Validatable; - -final class ConsonantException extends FilteredValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain only consonants', - AbstractFilterRule::TEMPLATE_EXTRA => '{{name}} must contain only consonants and {{additionalChars}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain consonants', - AbstractFilterRule::TEMPLATE_EXTRA => '{{name}} must not contain consonants or {{additionalChars}}', - ], - ]; -} diff --git a/library/Exceptions/ContainsAnyException.php b/library/Exceptions/ContainsAnyException.php deleted file mode 100644 index b98e26b7d..000000000 --- a/library/Exceptions/ContainsAnyException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ContainsAnyException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain at least one of the values {{needles}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain any of the values {{needles}}', - ], - ]; -} diff --git a/library/Exceptions/ContainsException.php b/library/Exceptions/ContainsException.php deleted file mode 100644 index 4191f4e69..000000000 --- a/library/Exceptions/ContainsException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ContainsException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain the value {{containsValue}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain the value {{containsValue}}', - ], - ]; -} diff --git a/library/Exceptions/ControlException.php b/library/Exceptions/ControlException.php deleted file mode 100644 index 640d8ab81..000000000 --- a/library/Exceptions/ControlException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\AbstractFilterRule as Filter; -use Respect\Validation\Validatable; - -final class ControlException extends FilteredValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain only control characters', - Filter::TEMPLATE_EXTRA => '{{name}} must contain only control characters and {{additionalChars}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain control characters', - Filter::TEMPLATE_EXTRA => '{{name}} must not contain control characters or {{additionalChars}}', - ], - ]; -} diff --git a/library/Exceptions/CountableException.php b/library/Exceptions/CountableException.php deleted file mode 100644 index e7b71ec09..000000000 --- a/library/Exceptions/CountableException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class CountableException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be countable', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be countable', - ], - ]; -} diff --git a/library/Exceptions/CountryCodeException.php b/library/Exceptions/CountryCodeException.php deleted file mode 100644 index 7e6dc9e52..000000000 --- a/library/Exceptions/CountryCodeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class CountryCodeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid country', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid country', - ], - ]; -} diff --git a/library/Exceptions/CpfException.php b/library/Exceptions/CpfException.php deleted file mode 100644 index 2ebf25ea2..000000000 --- a/library/Exceptions/CpfException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class CpfException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid CPF number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid CPF number', - ], - ]; -} diff --git a/library/Exceptions/CreditCardException.php b/library/Exceptions/CreditCardException.php deleted file mode 100644 index a5b89c385..000000000 --- a/library/Exceptions/CreditCardException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\CreditCard; -use Respect\Validation\Validatable; - -final class CreditCardException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid Credit Card number', - CreditCard::TEMPLATE_BRANDED => '{{name}} must be a valid {{brand}} Credit Card number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid Credit Card number', - CreditCard::TEMPLATE_BRANDED => '{{name}} must not be a valid {{brand}} Credit Card number', - ], - ]; -} diff --git a/library/Exceptions/CurrencyCodeException.php b/library/Exceptions/CurrencyCodeException.php deleted file mode 100644 index 36ee5f182..000000000 --- a/library/Exceptions/CurrencyCodeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class CurrencyCodeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid currency', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid currency', - ], - ]; -} diff --git a/library/Exceptions/DateException.php b/library/Exceptions/DateException.php deleted file mode 100644 index 158dad061..000000000 --- a/library/Exceptions/DateException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class DateException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid date in the format {{sample}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid date in the format {{sample}}', - ], - ]; -} diff --git a/library/Exceptions/DateTimeException.php b/library/Exceptions/DateTimeException.php deleted file mode 100644 index b3be71c17..000000000 --- a/library/Exceptions/DateTimeException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\DateTime; -use Respect\Validation\Validatable; - -final class DateTimeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid date/time', - DateTime::TEMPLATE_FORMAT => '{{name}} must be a valid date/time in the format {{sample}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid date/time', - DateTime::TEMPLATE_FORMAT => '{{name}} must not be a valid date/time in the format {{sample}}', - ], - ]; -} diff --git a/library/Exceptions/DecimalException.php b/library/Exceptions/DecimalException.php deleted file mode 100644 index b1d0abd9c..000000000 --- a/library/Exceptions/DecimalException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class DecimalException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must have {{decimals}} decimals', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not have {{decimals}} decimals', - ], - ]; -} diff --git a/library/Exceptions/DigitException.php b/library/Exceptions/DigitException.php deleted file mode 100644 index 76c88191a..000000000 --- a/library/Exceptions/DigitException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\AbstractFilterRule; -use Respect\Validation\Validatable; - -final class DigitException extends FilteredValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain only digits (0-9)', - AbstractFilterRule::TEMPLATE_EXTRA => '{{name}} must contain only digits (0-9) and {{additionalChars}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain digits (0-9)', - AbstractFilterRule::TEMPLATE_EXTRA => '{{name}} must not contain digits (0-9) and {{additionalChars}}', - ], - ]; -} diff --git a/library/Exceptions/DirectoryException.php b/library/Exceptions/DirectoryException.php deleted file mode 100644 index cb0e2bf92..000000000 --- a/library/Exceptions/DirectoryException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class DirectoryException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a directory', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a directory', - ], - ]; -} diff --git a/library/Exceptions/DomainException.php b/library/Exceptions/DomainException.php deleted file mode 100644 index 7c22abc34..000000000 --- a/library/Exceptions/DomainException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class DomainException extends NestedValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid domain', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid domain', - ], - ]; -} diff --git a/library/Exceptions/EachException.php b/library/Exceptions/EachException.php index 6d04f7a27..d9134f101 100644 --- a/library/Exceptions/EachException.php +++ b/library/Exceptions/EachException.php @@ -9,22 +9,8 @@ namespace Respect\Validation\Exceptions; -use Respect\Validation\Validatable; - final class EachException extends NestedValidationException { - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'Each item in {{name}} must be valid', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'Each item in {{name}} must not validate', - ], - ]; - /** * @todo This method shares too much with the parent implementation * diff --git a/library/Exceptions/EmailException.php b/library/Exceptions/EmailException.php deleted file mode 100644 index 94f45b6a4..000000000 --- a/library/Exceptions/EmailException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class EmailException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be valid email', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an email', - ], - ]; -} diff --git a/library/Exceptions/EndsWithException.php b/library/Exceptions/EndsWithException.php deleted file mode 100644 index ebd05522f..000000000 --- a/library/Exceptions/EndsWithException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class EndsWithException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must end with {{endValue}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not end with {{endValue}}', - ], - ]; -} diff --git a/library/Exceptions/EqualsException.php b/library/Exceptions/EqualsException.php deleted file mode 100644 index 5d79bc0da..000000000 --- a/library/Exceptions/EqualsException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class EqualsException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must equal {{compareTo}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not equal {{compareTo}}', - ], - ]; -} diff --git a/library/Exceptions/EquivalentException.php b/library/Exceptions/EquivalentException.php deleted file mode 100644 index 094bacb80..000000000 --- a/library/Exceptions/EquivalentException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class EquivalentException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be equivalent to {{compareTo}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be equivalent to {{compareTo}}', - ], - ]; -} diff --git a/library/Exceptions/EvenException.php b/library/Exceptions/EvenException.php deleted file mode 100644 index 45cb645f1..000000000 --- a/library/Exceptions/EvenException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class EvenException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be an even number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an even number', - ], - ]; -} diff --git a/library/Exceptions/ExecutableException.php b/library/Exceptions/ExecutableException.php deleted file mode 100644 index b360f3bc8..000000000 --- a/library/Exceptions/ExecutableException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ExecutableException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be an executable file', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an executable file', - ], - ]; -} diff --git a/library/Exceptions/ExistsException.php b/library/Exceptions/ExistsException.php deleted file mode 100644 index e3877c84e..000000000 --- a/library/Exceptions/ExistsException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ExistsException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must exist', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not exist', - ], - ]; -} diff --git a/library/Exceptions/ExtensionException.php b/library/Exceptions/ExtensionException.php deleted file mode 100644 index 4a3d73a5f..000000000 --- a/library/Exceptions/ExtensionException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ExtensionException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must have {{extension}} extension', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not have {{extension}} extension', - ], - ]; -} diff --git a/library/Exceptions/FactorException.php b/library/Exceptions/FactorException.php deleted file mode 100644 index 662634132..000000000 --- a/library/Exceptions/FactorException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class FactorException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a factor of {{dividend}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a factor of {{dividend}}', - ], - ]; -} diff --git a/library/Exceptions/FalseValException.php b/library/Exceptions/FalseValException.php deleted file mode 100644 index 6899c65ff..000000000 --- a/library/Exceptions/FalseValException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class FalseValException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must evaluate to `false`', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not evaluate to `false`', - ], - ]; -} diff --git a/library/Exceptions/FibonacciException.php b/library/Exceptions/FibonacciException.php deleted file mode 100644 index 65db68072..000000000 --- a/library/Exceptions/FibonacciException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class FibonacciException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid Fibonacci number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid Fibonacci number', - ], - ]; -} diff --git a/library/Exceptions/FileException.php b/library/Exceptions/FileException.php deleted file mode 100644 index 3683474b2..000000000 --- a/library/Exceptions/FileException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class FileException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a file', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a file', - ], - ]; -} diff --git a/library/Exceptions/FilterVarException.php b/library/Exceptions/FilterVarException.php deleted file mode 100644 index b16b5d1b0..000000000 --- a/library/Exceptions/FilterVarException.php +++ /dev/null @@ -1,14 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -final class FilterVarException extends ValidationException -{ -} diff --git a/library/Exceptions/FilteredValidationException.php b/library/Exceptions/FilteredValidationException.php deleted file mode 100644 index 7cc6dcf5e..000000000 --- a/library/Exceptions/FilteredValidationException.php +++ /dev/null @@ -1,14 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -class FilteredValidationException extends ValidationException -{ -} diff --git a/library/Exceptions/FiniteException.php b/library/Exceptions/FiniteException.php deleted file mode 100644 index 31b227387..000000000 --- a/library/Exceptions/FiniteException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class FiniteException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a finite number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a finite number', - ], - ]; -} diff --git a/library/Exceptions/FloatTypeException.php b/library/Exceptions/FloatTypeException.php deleted file mode 100644 index 026862cbd..000000000 --- a/library/Exceptions/FloatTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class FloatTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be of type float', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be of type float', - ], - ]; -} diff --git a/library/Exceptions/FloatValException.php b/library/Exceptions/FloatValException.php deleted file mode 100644 index 4db516a49..000000000 --- a/library/Exceptions/FloatValException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class FloatValException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a float number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a float number', - ], - ]; -} diff --git a/library/Exceptions/GraphException.php b/library/Exceptions/GraphException.php deleted file mode 100644 index e03887b99..000000000 --- a/library/Exceptions/GraphException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\AbstractFilterRule as Filter; -use Respect\Validation\Validatable; - -final class GraphException extends FilteredValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain only graphical characters', - Filter::TEMPLATE_EXTRA => '{{name}} must contain only graphical characters and {{additionalChars}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain graphical characters', - Filter::TEMPLATE_EXTRA => '{{name}} must not contain graphical characters or {{additionalChars}}', - ], - ]; -} diff --git a/library/Exceptions/GreaterThanException.php b/library/Exceptions/GreaterThanException.php deleted file mode 100644 index 910eb56d4..000000000 --- a/library/Exceptions/GreaterThanException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class GreaterThanException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be greater than {{compareTo}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be greater than {{compareTo}}', - ], - ]; -} diff --git a/library/Exceptions/GroupedValidationException.php b/library/Exceptions/GroupedValidationException.php deleted file mode 100644 index e5f0b0200..000000000 --- a/library/Exceptions/GroupedValidationException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -class GroupedValidationException extends NestedValidationException -{ - public const NONE = 'none'; - public const SOME = 'some'; - - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - self::NONE => 'All of the required rules must pass for {{name}}', - self::SOME => 'These rules must pass for {{name}}', - ], - self::MODE_NEGATIVE => [ - self::NONE => 'None of there rules must pass for {{name}}', - self::SOME => 'These rules must not pass for {{name}}', - ], - ]; -} diff --git a/library/Exceptions/HexRgbColorException.php b/library/Exceptions/HexRgbColorException.php deleted file mode 100644 index 8732d92f8..000000000 --- a/library/Exceptions/HexRgbColorException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class HexRgbColorException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a hex RGB color', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a hex RGB color', - ], - ]; -} diff --git a/library/Exceptions/IbanException.php b/library/Exceptions/IbanException.php deleted file mode 100644 index 7ded2e324..000000000 --- a/library/Exceptions/IbanException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class IbanException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid IBAN', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid IBAN', - ], - ]; -} diff --git a/library/Exceptions/IdenticalException.php b/library/Exceptions/IdenticalException.php deleted file mode 100644 index 7773d1b37..000000000 --- a/library/Exceptions/IdenticalException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class IdenticalException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be identical as {{compareTo}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be identical as {{compareTo}}', - ], - ]; -} diff --git a/library/Exceptions/ImageException.php b/library/Exceptions/ImageException.php deleted file mode 100644 index 18363f453..000000000 --- a/library/Exceptions/ImageException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ImageException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid image', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid image', - ], - ]; -} diff --git a/library/Exceptions/ImeiException.php b/library/Exceptions/ImeiException.php deleted file mode 100644 index 0928f0828..000000000 --- a/library/Exceptions/ImeiException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ImeiException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid IMEI', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid IMEI', - ], - ]; -} diff --git a/library/Exceptions/InException.php b/library/Exceptions/InException.php deleted file mode 100644 index 5f3ad0a77..000000000 --- a/library/Exceptions/InException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class InException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be in {{haystack}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be in {{haystack}}', - ], - ]; -} diff --git a/library/Exceptions/InfiniteException.php b/library/Exceptions/InfiniteException.php deleted file mode 100644 index ad8cca2f4..000000000 --- a/library/Exceptions/InfiniteException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class InfiniteException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be an infinite number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an infinite number', - ], - ]; -} diff --git a/library/Exceptions/InstanceException.php b/library/Exceptions/InstanceException.php deleted file mode 100644 index 4fbf276aa..000000000 --- a/library/Exceptions/InstanceException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class InstanceException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be an instance of {{instanceName}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an instance of {{instanceName}}', - ], - ]; -} diff --git a/library/Exceptions/IntTypeException.php b/library/Exceptions/IntTypeException.php deleted file mode 100644 index 10739e5a6..000000000 --- a/library/Exceptions/IntTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class IntTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be of type integer', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be of type integer', - ], - ]; -} diff --git a/library/Exceptions/IntValException.php b/library/Exceptions/IntValException.php deleted file mode 100644 index dd901300b..000000000 --- a/library/Exceptions/IntValException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class IntValException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be an integer number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an integer number', - ], - ]; -} diff --git a/library/Exceptions/IpException.php b/library/Exceptions/IpException.php deleted file mode 100644 index 4b09fe2f3..000000000 --- a/library/Exceptions/IpException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Ip; -use Respect\Validation\Validatable; - -final class IpException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be an IP address', - Ip::TEMPLATE_NETWORK_RANGE => '{{name}} must be an IP address in the {{range}} range', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an IP address', - Ip::TEMPLATE_NETWORK_RANGE => '{{name}} must not be an IP address in the {{range}} range', - ], - ]; -} diff --git a/library/Exceptions/IsbnException.php b/library/Exceptions/IsbnException.php deleted file mode 100644 index e066ca5c4..000000000 --- a/library/Exceptions/IsbnException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class IsbnException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a ISBN', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a ISBN', - ], - ]; -} diff --git a/library/Exceptions/IterableTypeException.php b/library/Exceptions/IterableTypeException.php deleted file mode 100644 index 6d638273c..000000000 --- a/library/Exceptions/IterableTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class IterableTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be iterable', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be iterable', - ], - ]; -} diff --git a/library/Exceptions/JsonException.php b/library/Exceptions/JsonException.php deleted file mode 100644 index 9a34236ad..000000000 --- a/library/Exceptions/JsonException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class JsonException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid JSON string', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid JSON string', - ], - ]; -} diff --git a/library/Exceptions/KeyException.php b/library/Exceptions/KeyException.php deleted file mode 100644 index e64633e5c..000000000 --- a/library/Exceptions/KeyException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Key; - -final class KeyException extends NestedValidationException implements NonOmissibleException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Key::TEMPLATE_NOT_PRESENT => '{{name}} must be present', - Key::TEMPLATE_INVALID => '{{name}} must be valid', - ], - self::MODE_NEGATIVE => [ - Key::TEMPLATE_NOT_PRESENT => '{{name}} must not be present', - Key::TEMPLATE_INVALID => '{{name}} must not be valid', - ], - ]; -} diff --git a/library/Exceptions/KeyNestedException.php b/library/Exceptions/KeyNestedException.php deleted file mode 100644 index a868c1c8e..000000000 --- a/library/Exceptions/KeyNestedException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\KeyNested; - -final class KeyNestedException extends NestedValidationException implements NonOmissibleException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - KeyNested::TEMPLATE_NOT_PRESENT => 'No items were found for key chain {{name}}', - KeyNested::TEMPLATE_INVALID => 'Key chain {{name}} is not valid', - ], - self::MODE_NEGATIVE => [ - KeyNested::TEMPLATE_NOT_PRESENT => 'Items for key chain {{name}} must not be present', - KeyNested::TEMPLATE_INVALID => 'Key chain {{name}} must not be valid', - ], - ]; -} diff --git a/library/Exceptions/KeySetException.php b/library/Exceptions/KeySetException.php deleted file mode 100644 index d67005588..000000000 --- a/library/Exceptions/KeySetException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\KeySet; - -final class KeySetException extends GroupedValidationException implements NonOmissibleException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - KeySet::TEMPLATE_NONE => 'All of the required rules must pass for {{name}}', - KeySet::TEMPLATE_SOME => 'These rules must pass for {{name}}', - KeySet::TEMPLATE_STRUCTURE => 'Must have keys {{keys}}', - KeySet::TEMPLATE_STRUCTURE_EXTRA => 'Must not have keys {{extraKeys}}', - ], - ]; -} diff --git a/library/Exceptions/KeyValueException.php b/library/Exceptions/KeyValueException.php deleted file mode 100644 index 72296e32b..000000000 --- a/library/Exceptions/KeyValueException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\KeyValue; -use Respect\Validation\Validatable; - -final class KeyValueException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'Key {{name}} must be present', - KeyValue::TEMPLATE_COMPONENT => '{{baseKey}} must be valid to validate {{comparedKey}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'Key {{name}} must not be present', - KeyValue::TEMPLATE_COMPONENT => '{{baseKey}} must not be valid to validate {{comparedKey}}', - ], - ]; -} diff --git a/library/Exceptions/LanguageCodeException.php b/library/Exceptions/LanguageCodeException.php deleted file mode 100644 index 7924fcb6e..000000000 --- a/library/Exceptions/LanguageCodeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class LanguageCodeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid ISO 639 {{set}} language code', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid ISO 639 {{set}} language code', - ], - ]; -} diff --git a/library/Exceptions/LeapDateException.php b/library/Exceptions/LeapDateException.php deleted file mode 100644 index 8de0466af..000000000 --- a/library/Exceptions/LeapDateException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class LeapDateException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be leap date', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be leap date', - ], - ]; -} diff --git a/library/Exceptions/LeapYearException.php b/library/Exceptions/LeapYearException.php deleted file mode 100644 index cf9295d3a..000000000 --- a/library/Exceptions/LeapYearException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class LeapYearException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a leap year', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a leap year', - ], - ]; -} diff --git a/library/Exceptions/LengthException.php b/library/Exceptions/LengthException.php deleted file mode 100644 index 9c8db9604..000000000 --- a/library/Exceptions/LengthException.php +++ /dev/null @@ -1,37 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Length; - -final class LengthException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Length::TEMPLATE_BOTH => '{{name}} must have a length between {{minValue}} and {{maxValue}}', - Length::TEMPLATE_LOWER => '{{name}} must have a length greater than {{minValue}}', - Length::TEMPLATE_LOWER_INCLUSIVE => '{{name}} must have a length greater than or equal to {{minValue}}', - Length::TEMPLATE_GREATER => '{{name}} must have a length lower than {{maxValue}}', - Length::TEMPLATE_GREATER_INCLUSIVE => '{{name}} must have a length lower than or equal to {{maxValue}}', - Length::TEMPLATE_EXACT => '{{name}} must have a length of {{maxValue}}', - ], - self::MODE_NEGATIVE => [ - Length::TEMPLATE_BOTH => '{{name}} must not have a length between {{minValue}} and {{maxValue}}', - Length::TEMPLATE_LOWER => '{{name}} must not have a length greater than {{minValue}}', - Length::TEMPLATE_LOWER_INCLUSIVE => '{{name}} must not have a length greater than or equal to {{minValue}}', - Length::TEMPLATE_GREATER => '{{name}} must not have a length lower than {{maxValue}}', - Length::TEMPLATE_GREATER_INCLUSIVE => '{{name}} must not have a length lower than or equal to {{maxValue}}', - Length::TEMPLATE_EXACT => '{{name}} must not have a length of {{maxValue}}', - ], - ]; -} diff --git a/library/Exceptions/LessThanException.php b/library/Exceptions/LessThanException.php deleted file mode 100644 index bfe12d220..000000000 --- a/library/Exceptions/LessThanException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class LessThanException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be less than {{compareTo}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be less than {{compareTo}}', - ], - ]; -} diff --git a/library/Exceptions/LowercaseException.php b/library/Exceptions/LowercaseException.php deleted file mode 100644 index c39631868..000000000 --- a/library/Exceptions/LowercaseException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class LowercaseException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be lowercase', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be lowercase', - ], - ]; -} diff --git a/library/Exceptions/LuhnException.php b/library/Exceptions/LuhnException.php deleted file mode 100644 index ed103c28f..000000000 --- a/library/Exceptions/LuhnException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class LuhnException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid Luhn number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid Luhn number', - ], - ]; -} diff --git a/library/Exceptions/MacAddressException.php b/library/Exceptions/MacAddressException.php deleted file mode 100644 index f6a7359a1..000000000 --- a/library/Exceptions/MacAddressException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class MacAddressException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid MAC address', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid MAC address', - ], - ]; -} diff --git a/library/Exceptions/MaxAgeException.php b/library/Exceptions/MaxAgeException.php deleted file mode 100644 index b2d45184e..000000000 --- a/library/Exceptions/MaxAgeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class MaxAgeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be {{age}} years or less', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be {{age}} years or less', - ], - ]; -} diff --git a/library/Exceptions/MaxException.php b/library/Exceptions/MaxException.php deleted file mode 100644 index 8f1fdbcfe..000000000 --- a/library/Exceptions/MaxException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class MaxException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be less than or equal to {{compareTo}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be less than or equal to {{compareTo}}', - ], - ]; -} diff --git a/library/Exceptions/MimetypeException.php b/library/Exceptions/MimetypeException.php deleted file mode 100644 index 354ea2ab6..000000000 --- a/library/Exceptions/MimetypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class MimetypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must have {{mimetype}} MIME type', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not have {{mimetype}} MIME type', - ], - ]; -} diff --git a/library/Exceptions/MinAgeException.php b/library/Exceptions/MinAgeException.php deleted file mode 100644 index 698cb758a..000000000 --- a/library/Exceptions/MinAgeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class MinAgeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be {{age}} years or more', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be {{age}} years or more', - ], - ]; -} diff --git a/library/Exceptions/MinException.php b/library/Exceptions/MinException.php deleted file mode 100644 index 9fea0c311..000000000 --- a/library/Exceptions/MinException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class MinException extends ValidationException -{ - public const INCLUSIVE = 'inclusive'; - - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be greater than or equal to {{compareTo}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be greater than or equal to {{compareTo}}', - ], - ]; -} diff --git a/library/Exceptions/MultipleException.php b/library/Exceptions/MultipleException.php deleted file mode 100644 index 724106d3b..000000000 --- a/library/Exceptions/MultipleException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class MultipleException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be multiple of {{multipleOf}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be multiple of {{multipleOf}}', - ], - ]; -} diff --git a/library/Exceptions/NegativeException.php b/library/Exceptions/NegativeException.php deleted file mode 100644 index 0ab2ca383..000000000 --- a/library/Exceptions/NegativeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NegativeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be negative', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be negative', - ], - ]; -} diff --git a/library/Exceptions/NestedValidationException.php b/library/Exceptions/NestedValidationException.php index 1dfc2cb77..898442880 100644 --- a/library/Exceptions/NestedValidationException.php +++ b/library/Exceptions/NestedValidationException.php @@ -231,6 +231,6 @@ private function isOmissible(Exception $exception): bool return $childException->hasCustomTemplate(); } - return !$childException instanceof NonOmissibleException; + return !$childException instanceof NonOmissibleValidationException; } } diff --git a/library/Exceptions/NfeAccessKeyException.php b/library/Exceptions/NfeAccessKeyException.php deleted file mode 100644 index b95beb5c6..000000000 --- a/library/Exceptions/NfeAccessKeyException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NfeAccessKeyException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid NFe access key', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid NFe access key', - ], - ]; -} diff --git a/library/Exceptions/NifException.php b/library/Exceptions/NifException.php deleted file mode 100644 index 2e6169660..000000000 --- a/library/Exceptions/NifException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NifException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a NIF', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a NIF', - ], - ]; -} diff --git a/library/Exceptions/NipException.php b/library/Exceptions/NipException.php deleted file mode 100644 index 467d93449..000000000 --- a/library/Exceptions/NipException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NipException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid Polish VAT identification number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid Polish VAT identification number', - ], - ]; -} diff --git a/library/Exceptions/NoException.php b/library/Exceptions/NoException.php deleted file mode 100644 index dbadc1828..000000000 --- a/library/Exceptions/NoException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NoException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be similar to "No"', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be similar to "No"', - ], - ]; -} diff --git a/library/Exceptions/NoWhitespaceException.php b/library/Exceptions/NoWhitespaceException.php deleted file mode 100644 index 3de5271f9..000000000 --- a/library/Exceptions/NoWhitespaceException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NoWhitespaceException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain whitespace', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain whitespace', - ], - ]; -} diff --git a/library/Exceptions/NonOmissibleException.php b/library/Exceptions/NonOmissibleException.php deleted file mode 100644 index 87d11b279..000000000 --- a/library/Exceptions/NonOmissibleException.php +++ /dev/null @@ -1,14 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -interface NonOmissibleException extends Exception -{ -} diff --git a/library/Exceptions/CallbackException.php b/library/Exceptions/NonOmissibleValidationException.php similarity index 69% rename from library/Exceptions/CallbackException.php rename to library/Exceptions/NonOmissibleValidationException.php index b6b506220..365837b1b 100644 --- a/library/Exceptions/CallbackException.php +++ b/library/Exceptions/NonOmissibleValidationException.php @@ -9,6 +9,6 @@ namespace Respect\Validation\Exceptions; -final class CallbackException extends NestedValidationException +final class NonOmissibleValidationException extends NestedValidationException { } diff --git a/library/Exceptions/NoneOfException.php b/library/Exceptions/NoneOfException.php deleted file mode 100644 index 13e1e3db2..000000000 --- a/library/Exceptions/NoneOfException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NoneOfException extends NestedValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'None of these rules must pass for {{name}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'All of these rules must pass for {{name}}', - ], - ]; -} diff --git a/library/Exceptions/NotBlankException.php b/library/Exceptions/NotBlankException.php deleted file mode 100644 index 8b5f564b9..000000000 --- a/library/Exceptions/NotBlankException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\NotBlank; -use Respect\Validation\Validatable; - -final class NotBlankException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'The value must not be blank', - NotBlank::TEMPLATE_NAMED => '{{name}} must not be blank', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'The value must be blank', - NotBlank::TEMPLATE_NAMED => '{{name}} must be blank', - ], - ]; -} diff --git a/library/Exceptions/NotEmojiException.php b/library/Exceptions/NotEmojiException.php deleted file mode 100644 index 6c61fc0c5..000000000 --- a/library/Exceptions/NotEmojiException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NotEmojiException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain an Emoji', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain an Emoji', - ], - ]; -} diff --git a/library/Exceptions/NotEmptyException.php b/library/Exceptions/NotEmptyException.php deleted file mode 100644 index ab5619c17..000000000 --- a/library/Exceptions/NotEmptyException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\NotEmpty; -use Respect\Validation\Validatable; - -final class NotEmptyException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'The value must not be empty', - NotEmpty::TEMPLATE_NAMED => '{{name}} must not be empty', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'The value must be empty', - NotEmpty::TEMPLATE_NAMED => '{{name}} must be empty', - ], - ]; -} diff --git a/library/Exceptions/NotException.php b/library/Exceptions/NotException.php deleted file mode 100644 index 0162e5a3f..000000000 --- a/library/Exceptions/NotException.php +++ /dev/null @@ -1,14 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -final class NotException extends GroupedValidationException -{ -} diff --git a/library/Exceptions/NotOptionalException.php b/library/Exceptions/NotOptionalException.php deleted file mode 100644 index b24e1d481..000000000 --- a/library/Exceptions/NotOptionalException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\NotOptional; -use Respect\Validation\Validatable; - -final class NotOptionalException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'The value must not be optional', - NotOptional::TEMPLATE_NAMED => '{{name}} must not be optional', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'The value must be optional', - NotOptional::TEMPLATE_NAMED => '{{name}} must be optional', - ], - ]; -} diff --git a/library/Exceptions/NullTypeException.php b/library/Exceptions/NullTypeException.php deleted file mode 100644 index 7a4469bdf..000000000 --- a/library/Exceptions/NullTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NullTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be null', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be null', - ], - ]; -} diff --git a/library/Exceptions/NullableException.php b/library/Exceptions/NullableException.php deleted file mode 100644 index 33220ec84..000000000 --- a/library/Exceptions/NullableException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Nullable; -use Respect\Validation\Validatable; - -final class NullableException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'The value must be nullable', - Nullable::TEMPLATE_NAMED => '{{name}} must be nullable', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'The value must not be null', - Nullable::TEMPLATE_NAMED => '{{name}} must not be null', - ], - ]; -} diff --git a/library/Exceptions/NumberException.php b/library/Exceptions/NumberException.php deleted file mode 100644 index 72aaae6dd..000000000 --- a/library/Exceptions/NumberException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NumberException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a number', - ], - ]; -} diff --git a/library/Exceptions/NumericValException.php b/library/Exceptions/NumericValException.php deleted file mode 100644 index 3ca632de3..000000000 --- a/library/Exceptions/NumericValException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class NumericValException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be numeric', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be numeric', - ], - ]; -} diff --git a/library/Exceptions/ObjectTypeException.php b/library/Exceptions/ObjectTypeException.php deleted file mode 100644 index 4a5b7fa3b..000000000 --- a/library/Exceptions/ObjectTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ObjectTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be of type object', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be of type object', - ], - ]; -} diff --git a/library/Exceptions/OddException.php b/library/Exceptions/OddException.php deleted file mode 100644 index c649b4f35..000000000 --- a/library/Exceptions/OddException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class OddException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be an odd number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an odd number', - ], - ]; -} diff --git a/library/Exceptions/OneOfException.php b/library/Exceptions/OneOfException.php deleted file mode 100644 index baea0fc4d..000000000 --- a/library/Exceptions/OneOfException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class OneOfException extends NestedValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'Only one of these rules must pass for {{name}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'Only one of these rules must not pass for {{name}}', - ], - ]; -} diff --git a/library/Exceptions/OptionalException.php b/library/Exceptions/OptionalException.php deleted file mode 100644 index 7b473fafd..000000000 --- a/library/Exceptions/OptionalException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Optional; -use Respect\Validation\Validatable; - -final class OptionalException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => 'The value must be optional', - Optional::TEMPLATE_NAMED => '{{name}} must be optional', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => 'The value must not be optional', - Optional::TEMPLATE_NAMED => '{{name}} must not be optional', - ], - ]; -} diff --git a/library/Exceptions/PerfectSquareException.php b/library/Exceptions/PerfectSquareException.php deleted file mode 100644 index 35e4dac32..000000000 --- a/library/Exceptions/PerfectSquareException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class PerfectSquareException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid perfect square', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid perfect square', - ], - ]; -} diff --git a/library/Exceptions/PeselException.php b/library/Exceptions/PeselException.php deleted file mode 100644 index b9e802011..000000000 --- a/library/Exceptions/PeselException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class PeselException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid PESEL', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid PESEL', - ], - ]; -} diff --git a/library/Exceptions/PhoneException.php b/library/Exceptions/PhoneException.php deleted file mode 100644 index 58389fc86..000000000 --- a/library/Exceptions/PhoneException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Phone; - -final class PhoneException extends ValidationException -{ - public const FOR_COUNTRY = 'for_country'; - public const INTERNATIONAL = 'international'; - - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Phone::TEMPLATE_INTERNATIONAL => '{{name}} must be a valid telephone number', - Phone::TEMPLATE_FOR_COUNTRY => '{{name}} must be a valid telephone number for country {{countryName}}', - ], - self::MODE_NEGATIVE => [ - Phone::TEMPLATE_INTERNATIONAL => '{{name}} must not be a valid telephone number', - Phone::TEMPLATE_FOR_COUNTRY => '{{name}} must not be a valid telephone number for country {{countryName}}', - ], - ]; -} diff --git a/library/Exceptions/PhpLabelException.php b/library/Exceptions/PhpLabelException.php deleted file mode 100644 index 02abfc03d..000000000 --- a/library/Exceptions/PhpLabelException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class PhpLabelException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid PHP label', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid PHP label', - ], - ]; -} diff --git a/library/Exceptions/PisException.php b/library/Exceptions/PisException.php deleted file mode 100644 index f5e139dd5..000000000 --- a/library/Exceptions/PisException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class PisException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid PIS number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid PIS number', - ], - ]; -} diff --git a/library/Exceptions/PolishIdCardException.php b/library/Exceptions/PolishIdCardException.php deleted file mode 100644 index 486912a06..000000000 --- a/library/Exceptions/PolishIdCardException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class PolishIdCardException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid Polish Identity Card number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid Polish Identity Card number', - ], - ]; -} diff --git a/library/Exceptions/PortugueseNifException.php b/library/Exceptions/PortugueseNifException.php deleted file mode 100644 index e16d12237..000000000 --- a/library/Exceptions/PortugueseNifException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class PortugueseNifException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a Portuguese NIF', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a Portuguese NIF', - ], - ]; -} diff --git a/library/Exceptions/PositiveException.php b/library/Exceptions/PositiveException.php deleted file mode 100644 index 75472ac24..000000000 --- a/library/Exceptions/PositiveException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class PositiveException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be positive', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be positive', - ], - ]; -} diff --git a/library/Exceptions/PostalCodeException.php b/library/Exceptions/PostalCodeException.php deleted file mode 100644 index e59029b22..000000000 --- a/library/Exceptions/PostalCodeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class PostalCodeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid postal code on {{countryCode}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid postal code on {{countryCode}}', - ], - ]; -} diff --git a/library/Exceptions/PrimeNumberException.php b/library/Exceptions/PrimeNumberException.php deleted file mode 100644 index c0d38fcb7..000000000 --- a/library/Exceptions/PrimeNumberException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class PrimeNumberException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid prime number', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid prime number', - ], - ]; -} diff --git a/library/Exceptions/PrintableException.php b/library/Exceptions/PrintableException.php deleted file mode 100644 index 6885cc96f..000000000 --- a/library/Exceptions/PrintableException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\AbstractFilterRule as Filter; -use Respect\Validation\Validatable; - -final class PrintableException extends FilteredValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain only printable characters', - Filter::TEMPLATE_EXTRA => '{{name}} must contain only printable characters and "{{additionalChars}}"', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain printable characters', - Filter::TEMPLATE_EXTRA => '{{name}} must not contain printable characters or "{{additionalChars}}"', - ], - ]; -} diff --git a/library/Exceptions/PropertyException.php b/library/Exceptions/PropertyException.php deleted file mode 100644 index eba3f4d52..000000000 --- a/library/Exceptions/PropertyException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Property; - -final class PropertyException extends NestedValidationException implements NonOmissibleException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Property::TEMPLATE_NOT_PRESENT => 'Property {{name}} must be present', - Property::TEMPLATE_INVALID => 'Property {{name}} must be valid', - ], - self::MODE_NEGATIVE => [ - Property::TEMPLATE_NOT_PRESENT => 'Property {{name}} must not be present', - Property::TEMPLATE_INVALID => 'Property {{name}} must not validate', - ], - ]; -} diff --git a/library/Exceptions/PublicDomainSuffixException.php b/library/Exceptions/PublicDomainSuffixException.php deleted file mode 100644 index 653fa32bd..000000000 --- a/library/Exceptions/PublicDomainSuffixException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -class PublicDomainSuffixException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a public domain suffix', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a public domain suffix', - ], - ]; -} diff --git a/library/Exceptions/PunctException.php b/library/Exceptions/PunctException.php deleted file mode 100644 index 3e93e8634..000000000 --- a/library/Exceptions/PunctException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\AbstractFilterRule as Filter; -use Respect\Validation\Validatable; - -final class PunctException extends FilteredValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain only punctuation characters', - Filter::TEMPLATE_EXTRA => '{{name}} must contain only punctuation characters and {{additionalChars}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain punctuation characters', - Filter::TEMPLATE_EXTRA => '{{name}} must not contain punctuation characters or {{additionalChars}}', - ], - ]; -} diff --git a/library/Exceptions/ReadableException.php b/library/Exceptions/ReadableException.php deleted file mode 100644 index 529a9baeb..000000000 --- a/library/Exceptions/ReadableException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ReadableException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be readable', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be readable', - ], - ]; -} diff --git a/library/Exceptions/RegexException.php b/library/Exceptions/RegexException.php deleted file mode 100644 index 1b107f91b..000000000 --- a/library/Exceptions/RegexException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class RegexException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must validate against {{regex}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not validate against {{regex}}', - ], - ]; -} diff --git a/library/Exceptions/ResourceTypeException.php b/library/Exceptions/ResourceTypeException.php deleted file mode 100644 index 9e9713332..000000000 --- a/library/Exceptions/ResourceTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ResourceTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a resource', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a resource', - ], - ]; -} diff --git a/library/Exceptions/RomanException.php b/library/Exceptions/RomanException.php deleted file mode 100644 index e1032794a..000000000 --- a/library/Exceptions/RomanException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class RomanException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid Roman numeral', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid Roman numeral', - ], - ]; -} diff --git a/library/Exceptions/ScalarValException.php b/library/Exceptions/ScalarValException.php deleted file mode 100644 index 01d626a7c..000000000 --- a/library/Exceptions/ScalarValException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class ScalarValException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a scalar value', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a scalar value', - ], - ]; -} diff --git a/library/Exceptions/SizeException.php b/library/Exceptions/SizeException.php deleted file mode 100644 index a83b73f46..000000000 --- a/library/Exceptions/SizeException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Size; - -final class SizeException extends NestedValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Size::TEMPLATE_BOTH => '{{name}} must be between {{minSize}} and {{maxSize}}', - Size::TEMPLATE_LOWER => '{{name}} must be greater than {{minSize}}', - Size::TEMPLATE_GREATER => '{{name}} must be lower than {{maxSize}}', - ], - self::MODE_NEGATIVE => [ - Size::TEMPLATE_BOTH => '{{name}} must not be between {{minSize}} and {{maxSize}}', - Size::TEMPLATE_LOWER => '{{name}} must not be greater than {{minSize}}', - Size::TEMPLATE_GREATER => '{{name}} must not be lower than {{maxSize}}', - ], - ]; -} diff --git a/library/Exceptions/SlugException.php b/library/Exceptions/SlugException.php deleted file mode 100644 index c73e985c3..000000000 --- a/library/Exceptions/SlugException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class SlugException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid slug', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid slug', - ], - ]; -} diff --git a/library/Exceptions/SortedException.php b/library/Exceptions/SortedException.php deleted file mode 100644 index be5c064a1..000000000 --- a/library/Exceptions/SortedException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Sorted; - -final class SortedException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Sorted::TEMPLATE_ASCENDING => '{{name}} must be sorted in ascending order', - Sorted::TEMPLATE_DESCENDING => '{{name}} must be sorted in descending order', - ], - self::MODE_NEGATIVE => [ - Sorted::TEMPLATE_ASCENDING => '{{name}} must not be sorted in ascending order', - Sorted::TEMPLATE_DESCENDING => '{{name}} must not be sorted in descending order', - ], - ]; -} diff --git a/library/Exceptions/SpaceException.php b/library/Exceptions/SpaceException.php deleted file mode 100644 index 002b094e2..000000000 --- a/library/Exceptions/SpaceException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\AbstractFilterRule; -use Respect\Validation\Validatable; - -final class SpaceException extends FilteredValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain only space characters', - AbstractFilterRule::TEMPLATE_EXTRA => '{{name}} must contain only space characters and {{additionalChars}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain space characters', - AbstractFilterRule::TEMPLATE_EXTRA => '{{name}} must not contain space characters or {{additionalChars}}', - ], - ]; -} diff --git a/library/Exceptions/StartsWithException.php b/library/Exceptions/StartsWithException.php deleted file mode 100644 index 30102be4a..000000000 --- a/library/Exceptions/StartsWithException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class StartsWithException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must start with {{startValue}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not start with {{startValue}}', - ], - ]; -} diff --git a/library/Exceptions/StringTypeException.php b/library/Exceptions/StringTypeException.php deleted file mode 100644 index 20b5162ca..000000000 --- a/library/Exceptions/StringTypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class StringTypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be of type string', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be of type string', - ], - ]; -} diff --git a/library/Exceptions/StringValException.php b/library/Exceptions/StringValException.php deleted file mode 100644 index c3b4af9c5..000000000 --- a/library/Exceptions/StringValException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class StringValException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a string', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be string', - ], - ]; -} diff --git a/library/Exceptions/SubdivisionCodeException.php b/library/Exceptions/SubdivisionCodeException.php deleted file mode 100644 index 83cc24a12..000000000 --- a/library/Exceptions/SubdivisionCodeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -class SubdivisionCodeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a subdivision code of {{countryName}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a subdivision code of {{countryName}}', - ], - ]; -} diff --git a/library/Exceptions/SubsetException.php b/library/Exceptions/SubsetException.php deleted file mode 100644 index 165e05eda..000000000 --- a/library/Exceptions/SubsetException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class SubsetException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be subset of {{superset}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be subset of {{superset}}', - ], - ]; -} diff --git a/library/Exceptions/SymbolicLinkException.php b/library/Exceptions/SymbolicLinkException.php deleted file mode 100644 index fc98b99b9..000000000 --- a/library/Exceptions/SymbolicLinkException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class SymbolicLinkException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a symbolic link', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a symbolic link', - ], - ]; -} diff --git a/library/Exceptions/TimeException.php b/library/Exceptions/TimeException.php deleted file mode 100644 index 45a213ecb..000000000 --- a/library/Exceptions/TimeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class TimeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid time in the format {{sample}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid time in the format {{sample}}', - ], - ]; -} diff --git a/library/Exceptions/TldException.php b/library/Exceptions/TldException.php deleted file mode 100644 index dc9370b26..000000000 --- a/library/Exceptions/TldException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class TldException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid top-level domain name', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid top-level domain name', - ], - ]; -} diff --git a/library/Exceptions/TrueValException.php b/library/Exceptions/TrueValException.php deleted file mode 100644 index ded96c7c1..000000000 --- a/library/Exceptions/TrueValException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class TrueValException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must evaluate to `true`', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not evaluate to `true`', - ], - ]; -} diff --git a/library/Exceptions/TypeException.php b/library/Exceptions/TypeException.php deleted file mode 100644 index fe1efdc93..000000000 --- a/library/Exceptions/TypeException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class TypeException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be {{type}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be {{type}}', - ], - ]; -} diff --git a/library/Exceptions/UniqueException.php b/library/Exceptions/UniqueException.php deleted file mode 100644 index fb1799f0a..000000000 --- a/library/Exceptions/UniqueException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class UniqueException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not contain duplicates', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must contain duplicates', - ], - ]; -} diff --git a/library/Exceptions/UploadedException.php b/library/Exceptions/UploadedException.php deleted file mode 100644 index c612499de..000000000 --- a/library/Exceptions/UploadedException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class UploadedException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be an uploaded file', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be an uploaded file', - ], - ]; -} diff --git a/library/Exceptions/UppercaseException.php b/library/Exceptions/UppercaseException.php deleted file mode 100644 index c6ad2ed02..000000000 --- a/library/Exceptions/UppercaseException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class UppercaseException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be uppercase', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be uppercase', - ], - ]; -} diff --git a/library/Exceptions/UrlException.php b/library/Exceptions/UrlException.php deleted file mode 100644 index 79e46a491..000000000 --- a/library/Exceptions/UrlException.php +++ /dev/null @@ -1,27 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Validatable; - -final class UrlException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a URL', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a URL', - ], - ]; -} diff --git a/library/Exceptions/UuidException.php b/library/Exceptions/UuidException.php deleted file mode 100644 index 514a2e9da..000000000 --- a/library/Exceptions/UuidException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * SPDX-License-Identifier: MIT - */ - -declare(strict_types=1); - -namespace Respect\Validation\Exceptions; - -use Respect\Validation\Rules\Uuid; -use Respect\Validation\Validatable; - -final class UuidException extends ValidationException -{ - /** - * @var array> - */ - protected array $defaultTemplates = [ - self::MODE_DEFAULT => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must be a valid UUID', - Uuid::TEMPLATE_VERSION => '{{name}} must be a valid UUID version {{version}}', - ], - self::MODE_NEGATIVE => [ - Validatable::TEMPLATE_STANDARD => '{{name}} must not be a valid UUID', - Uuid::TEMPLATE_VERSION => '{{name}} must not be a valid UUID version {{version}}', - ], - ]; -} diff --git a/library/Exceptions/ValidationException.php b/library/Exceptions/ValidationException.php index fa9a5170d..2a1683488 100644 --- a/library/Exceptions/ValidationException.php +++ b/library/Exceptions/ValidationException.php @@ -10,40 +10,40 @@ namespace Respect\Validation\Exceptions; use InvalidArgumentException; +use Respect\Validation\Attributes\Template; use Respect\Validation\Message\Formatter; -use Respect\Validation\Validatable; -use function key; +use function count; class ValidationException extends InvalidArgumentException implements Exception { public const MODE_DEFAULT = 'default'; public const MODE_NEGATIVE = 'negative'; + private string $mode = self::MODE_DEFAULT; + /** - * @var array> + * @var array