Skip to content

Commit

Permalink
Deprecate all exception classes
Browse files Browse the repository at this point in the history
It won't be possible to catch specific exceptions; users will need to
catch `ValidationException`. The `NestedValidationException` will be
removed in the next major version, but there's no alternative to it
right now, so I didn't deprecate it.
  • Loading branch information
henriquemoody committed Jan 6, 2025
1 parent 9740e24 commit 3c04d1d
Show file tree
Hide file tree
Showing 153 changed files with 153 additions and 38 deletions.
38 changes: 0 additions & 38 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,44 +79,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
<?php

/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/

declare(strict_types=1);

namespace Respect\Validation\Exceptions;

/**
* @author Your Name <youremail@yourdomain.tld>
*/
final class HelloWorldException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $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`
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/AllOfException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see NestedValidationException} instead.
*/
class AllOfException extends GroupedValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/AlnumException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class AlnumException extends FilteredValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/AlphaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class AlphaException extends FilteredValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/AlwaysInvalidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class AlwaysInvalidException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/AlwaysValidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class AlwaysValidException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/AnyOfException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class AnyOfException extends NestedValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/ArrayTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @author Emmerson Siqueira <[email protected]>
* @author Henrique Moody <[email protected]>
* @author João Torquato <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class ArrayTypeException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/ArrayValException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Emmerson Siqueira <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class ArrayValException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/AttributeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Emmerson Siqueira <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class AttributeException extends NestedValidationException implements NonOmissibleException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/Base64Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Henrique Moody <[email protected]>
* @author Jens Segers <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class Base64Exception extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/BaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Carlos André Ferrari <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class BaseException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/BetweenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class BetweenException extends NestedValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/BoolTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*
* @author Devin Torres <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class BoolTypeException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/BoolValException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Emmerson Siqueira <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class BoolValException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/BsnException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Henrique Moody <[email protected]>
* @author Ronald Drenth <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class BsnException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CallException extends NestedValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CallableTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Exception class for CallableType rule.
*
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CallableTypeException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CallbackException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CallbackException extends NestedValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CharsetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CharsetException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CnhException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Henrique Moody <[email protected]>
* @author Kinn Coelho Julião <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CnhException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CnpjException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Henrique Moody <[email protected]>
* @author Leonn Leite <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CnpjException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/ConsonantException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Henrique Moody <[email protected]>
* @author Danilo Correa <[email protected]>
* @author Kleber Hamada Sato <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class ConsonantException extends FilteredValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/ContainsAnyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* @author Kirill Dlussky <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class ContainsAnyException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/ContainsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class ContainsException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/ControlException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Andre Ramaciotti <[email protected]>
* @author Danilo Correa <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class ControlException extends FilteredValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CountableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Henrique Moody <[email protected]>
* @author João Torquato <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CountableException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CountryCodeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CountryCodeException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CpfException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Henrique Moody <[email protected]>
* @author Jair Henrique <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CpfException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CreditCardException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @author Henrique Moody <[email protected]>
* @author Jean Pimentel <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CreditCardException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/CurrencyCodeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Henrique Moody <[email protected]>
* @author Justin Hook <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class CurrencyCodeException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/DateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Bruno Luiz da Silva <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class DateException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/DateTimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class DateTimeException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/DecimalException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class DecimalException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/DigitException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class DigitException extends FilteredValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/DirectoryException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class DirectoryException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/DomainException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class DomainException extends NestedValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/EachException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class EachException extends NestedValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/EmailException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @author Eduardo Gulias Davis <[email protected]>
* @author Henrique Moody <[email protected]>
* @author Paul Karikari <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class EmailException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/EndsWithException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class EndsWithException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/EqualsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @author Alexandre Gomes Gaigalas <[email protected]>
* @author Henrique Moody <[email protected]>
* @author Ian Nisbet <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class EqualsException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/EquivalentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* @author Henrique Moody <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class EquivalentException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/EvenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @author Henrique Moody <[email protected]>
* @author Jean Pimentel <[email protected]>
* @author Paul Karikari <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class EvenException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/ExecutableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class ExecutableException extends ValidationException
{
Expand Down
1 change: 1 addition & 0 deletions library/Exceptions/ExistsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* @author Henrique Moody <[email protected]>
* @author William Espindola <[email protected]>
* @deprecated Using rule exceptions directly is deprecated, and will be removed in the next major version. Please use {@see ValidationException} instead.
*/
final class ExistsException extends ValidationException
{
Expand Down
Loading

0 comments on commit 3c04d1d

Please sign in to comment.