Skip to content

Commit f820f89

Browse files
committed
Rename InvalidRuleConstructorException to InvalidValidatorException
After renaming rules to validatores, it doesn't make sense to keep on having that exception. I renamed it to a more cleaner name, not mentioning the constructor because I think that if the constructor is not valid, the validator is not valid, hence the name I chose.
1 parent 8e5938a commit f820f89

46 files changed

Lines changed: 98 additions & 98 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

library/Exceptions/InvalidRuleConstructorException.php renamed to library/Exceptions/InvalidValidatorException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use function is_scalar;
1818
use function sprintf;
1919

20-
final class InvalidRuleConstructorException extends ComponentException implements Exception
20+
final class InvalidValidatorException extends ComponentException implements Exception
2121
{
2222
/** @param string|array<string> ...$arguments */
2323
public function __construct(string $message, string|array ...$arguments)

library/Validators/Base.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Respect\Validation\Validators;
1111

1212
use Attribute;
13-
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
13+
use Respect\Validation\Exceptions\InvalidValidatorException;
1414
use Respect\Validation\Message\Template;
1515
use Respect\Validation\Result;
1616
use Respect\Validation\Validator;
@@ -32,7 +32,7 @@ public function __construct(
3232
) {
3333
$max = mb_strlen($this->chars);
3434
if ($base > $max) {
35-
throw new InvalidRuleConstructorException('a base between 1 and %s is required', (string) $max);
35+
throw new InvalidValidatorException('a base between 1 and %s is required', (string) $max);
3636
}
3737
}
3838

library/Validators/Between.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Respect\Validation\Validators;
1111

1212
use Attribute;
13-
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
13+
use Respect\Validation\Exceptions\InvalidValidatorException;
1414
use Respect\Validation\Helpers\CanCompareValues;
1515
use Respect\Validation\Message\Template;
1616
use Respect\Validation\Validators\Core\Envelope;
@@ -27,7 +27,7 @@ final class Between extends Envelope
2727
public function __construct(mixed $minValue, mixed $maxValue)
2828
{
2929
if ($this->toComparable($minValue) >= $this->toComparable($maxValue)) {
30-
throw new InvalidRuleConstructorException('Minimum cannot be less than or equals to maximum');
30+
throw new InvalidValidatorException('Minimum cannot be less than or equals to maximum');
3131
}
3232

3333
parent::__construct(

library/Validators/BetweenExclusive.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Respect\Validation\Validators;
1111

1212
use Attribute;
13-
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
13+
use Respect\Validation\Exceptions\InvalidValidatorException;
1414
use Respect\Validation\Helpers\CanCompareValues;
1515
use Respect\Validation\Message\Template;
1616
use Respect\Validation\Validators\Core\Envelope;
@@ -27,7 +27,7 @@ final class BetweenExclusive extends Envelope
2727
public function __construct(mixed $minimum, mixed $maximum)
2828
{
2929
if ($this->toComparable($minimum) >= $this->toComparable($maximum)) {
30-
throw new InvalidRuleConstructorException('Minimum cannot be less than or equals to maximum');
30+
throw new InvalidValidatorException('Minimum cannot be less than or equals to maximum');
3131
}
3232

3333
parent::__construct(

library/Validators/Charset.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Respect\Validation\Validators;
1111

1212
use Attribute;
13-
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
13+
use Respect\Validation\Exceptions\InvalidValidatorException;
1414
use Respect\Validation\Message\Template;
1515
use Respect\Validation\Result;
1616
use Respect\Validation\Validator;
@@ -39,7 +39,7 @@ public function __construct(string $charset, string ...$charsets)
3939
$charsets = array_merge([$charset], $charsets);
4040
$diff = array_diff($charsets, $available);
4141
if (count($diff) > 0) {
42-
throw new InvalidRuleConstructorException('Invalid charset provided: %s', array_values($diff));
42+
throw new InvalidValidatorException('Invalid charset provided: %s', array_values($diff));
4343
}
4444

4545
$this->charset = $charsets;

library/Validators/ContainsAny.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Respect\Validation\Validators;
1111

1212
use Attribute;
13-
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
13+
use Respect\Validation\Exceptions\InvalidValidatorException;
1414
use Respect\Validation\Message\Template;
1515
use Respect\Validation\Validators\Core\Envelope;
1616

@@ -28,7 +28,7 @@ final class ContainsAny extends Envelope
2828
public function __construct(array $needles, bool $identical = false)
2929
{
3030
if (empty($needles)) {
31-
throw new InvalidRuleConstructorException('At least one value must be provided');
31+
throw new InvalidValidatorException('At least one value must be provided');
3232
}
3333

3434
$validators = $this->getValidators($needles, $identical);

library/Validators/CountryCode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Respect\Validation\Validators;
1111

1212
use Attribute;
13-
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
13+
use Respect\Validation\Exceptions\InvalidValidatorException;
1414
use Respect\Validation\Exceptions\MissingComposerDependencyException;
1515
use Respect\Validation\Message\Template;
1616
use Respect\Validation\Result;
@@ -45,7 +45,7 @@ public function __construct(
4545

4646
$availableOptions = ['alpha-2', 'alpha-3', 'numeric'];
4747
if (!in_array($set, $availableOptions, true)) {
48-
throw new InvalidRuleConstructorException(
48+
throw new InvalidValidatorException(
4949
'"%s" is not a valid set for ISO 3166-1 (Available: %s)',
5050
$set,
5151
$availableOptions,

library/Validators/CreditCard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Respect\Validation\Validators;
1111

1212
use Attribute;
13-
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
13+
use Respect\Validation\Exceptions\InvalidValidatorException;
1414
use Respect\Validation\Message\Template;
1515
use Respect\Validation\Result;
1616
use Respect\Validation\Validator;
@@ -58,7 +58,7 @@ public function __construct(
5858
private string $brand = self::ANY,
5959
) {
6060
if (!isset(self::BRAND_REGEX_LIST[$brand])) {
61-
throw new InvalidRuleConstructorException(
61+
throw new InvalidValidatorException(
6262
'"%s" is not a valid credit card brand (Available: %s)',
6363
$brand,
6464
array_keys(self::BRAND_REGEX_LIST),

library/Validators/CurrencyCode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Respect\Validation\Validators;
1111

1212
use Attribute;
13-
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
13+
use Respect\Validation\Exceptions\InvalidValidatorException;
1414
use Respect\Validation\Exceptions\MissingComposerDependencyException;
1515
use Respect\Validation\Message\Template;
1616
use Respect\Validation\Result;
@@ -44,7 +44,7 @@ public function __construct(
4444

4545
$availableSets = ['alpha-3', 'numeric'];
4646
if (!in_array($set, $availableSets, true)) {
47-
throw new InvalidRuleConstructorException(
47+
throw new InvalidValidatorException(
4848
'"%s" is not a valid set for ISO 4217 (Available: %s)',
4949
$set,
5050
$availableSets,

library/Validators/Date.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Respect\Validation\Validators;
1111

1212
use Attribute;
13-
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
13+
use Respect\Validation\Exceptions\InvalidValidatorException;
1414
use Respect\Validation\Helpers\CanValidateDateTime;
1515
use Respect\Validation\Message\Template;
1616
use Respect\Validation\Result;
@@ -34,7 +34,7 @@ public function __construct(
3434
private string $format = 'Y-m-d',
3535
) {
3636
if (!preg_match('/^[djSFmMnYy\W]+$/', $format)) {
37-
throw new InvalidRuleConstructorException('"%s" is not a valid date format', $format);
37+
throw new InvalidValidatorException('"%s" is not a valid date format', $format);
3838
}
3939
}
4040

0 commit comments

Comments
 (0)