Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use function is_scalar;
use function sprintf;

final class InvalidRuleConstructorException extends ComponentException implements Exception
final class InvalidValidatorException extends ComponentException implements Exception
{
/** @param string|array<string> ...$arguments */
public function __construct(string $message, string|array ...$arguments)
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
use Respect\Validation\Validator;
Expand All @@ -32,7 +32,7 @@ public function __construct(
) {
$max = mb_strlen($this->chars);
if ($base > $max) {
throw new InvalidRuleConstructorException('a base between 1 and %s is required', (string) $max);
throw new InvalidValidatorException('a base between 1 and %s is required', (string) $max);
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/Validators/Between.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

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

parent::__construct(
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/BetweenExclusive.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

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

parent::__construct(
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/Charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
use Respect\Validation\Validator;
Expand Down Expand Up @@ -39,7 +39,7 @@ public function __construct(string $charset, string ...$charsets)
$charsets = array_merge([$charset], $charsets);
$diff = array_diff($charsets, $available);
if (count($diff) > 0) {
throw new InvalidRuleConstructorException('Invalid charset provided: %s', array_values($diff));
throw new InvalidValidatorException('Invalid charset provided: %s', array_values($diff));
}

$this->charset = $charsets;
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/ContainsAny.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Validators\Core\Envelope;

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

$validators = $this->getValidators($needles, $identical);
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/CountryCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Exceptions\MissingComposerDependencyException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
Expand Down Expand Up @@ -45,7 +45,7 @@ public function __construct(

$availableOptions = ['alpha-2', 'alpha-3', 'numeric'];
if (!in_array($set, $availableOptions, true)) {
throw new InvalidRuleConstructorException(
throw new InvalidValidatorException(
'"%s" is not a valid set for ISO 3166-1 (Available: %s)',
$set,
$availableOptions,
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
use Respect\Validation\Validator;
Expand Down Expand Up @@ -58,7 +58,7 @@ public function __construct(
private string $brand = self::ANY,
) {
if (!isset(self::BRAND_REGEX_LIST[$brand])) {
throw new InvalidRuleConstructorException(
throw new InvalidValidatorException(
'"%s" is not a valid credit card brand (Available: %s)',
$brand,
array_keys(self::BRAND_REGEX_LIST),
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/CurrencyCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Exceptions\MissingComposerDependencyException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
Expand Down Expand Up @@ -44,7 +44,7 @@ public function __construct(

$availableSets = ['alpha-3', 'numeric'];
if (!in_array($set, $availableSets, true)) {
throw new InvalidRuleConstructorException(
throw new InvalidValidatorException(
'"%s" is not a valid set for ISO 4217 (Available: %s)',
$set,
$availableSets,
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Helpers\CanValidateDateTime;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
Expand All @@ -34,7 +34,7 @@ public function __construct(
private string $format = 'Y-m-d',
) {
if (!preg_match('/^[djSFmMnYy\W]+$/', $format)) {
throw new InvalidRuleConstructorException('"%s" is not a valid date format', $format);
throw new InvalidValidatorException('"%s" is not a valid date format', $format);
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/Validators/DateTimeDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Attribute;
use DateTimeImmutable;
use DateTimeInterface;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Helpers\CanValidateDateTime;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
Expand Down Expand Up @@ -59,7 +59,7 @@ public function __construct(
) {
$availableTypes = ['years', 'months', 'days', 'hours', 'minutes', 'seconds', 'microseconds'];
if (!in_array($this->type, $availableTypes, true)) {
throw new InvalidRuleConstructorException(
throw new InvalidValidatorException(
'"%s" is not a valid type of age (Available: %s)',
$this->type,
$availableTypes,
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/FilterVar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Validators\Core\Envelope;

Expand Down Expand Up @@ -49,7 +49,7 @@ final class FilterVar extends Envelope
public function __construct(int $filter, mixed $options = null)
{
if (!array_key_exists($filter, self::ALLOWED_FILTERS)) {
throw new InvalidRuleConstructorException('Cannot accept the given filter');
throw new InvalidValidatorException('Cannot accept the given filter');
}

$arguments = [$filter];
Expand Down
10 changes: 5 additions & 5 deletions library/Validators/Ip.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
use Respect\Validation\Validator;
Expand Down Expand Up @@ -107,11 +107,11 @@ private function parseRange(string $input): void
[$this->startAddress, $this->endAddress] = explode('-', $input);

if (is_string($this->startAddress) && !$this->verifyAddress($this->startAddress)) {
throw new InvalidRuleConstructorException('Invalid network range');
throw new InvalidValidatorException('Invalid network range');
}

if (is_string($this->endAddress) && !$this->verifyAddress($this->endAddress)) {
throw new InvalidRuleConstructorException('Invalid network range');
throw new InvalidValidatorException('Invalid network range');
}

return;
Expand All @@ -129,7 +129,7 @@ private function parseRange(string $input): void
return;
}

throw new InvalidRuleConstructorException('Invalid network range');
throw new InvalidValidatorException('Invalid network range');
}

private function fillAddress(string $address, string $fill = '*'): string
Expand Down Expand Up @@ -159,7 +159,7 @@ private function parseRangeUsingCidr(string $input): void
}

if ($isAddressMask || $parts[1] < 8 || $parts[1] > 30) {
throw new InvalidRuleConstructorException('Invalid network mask');
throw new InvalidValidatorException('Invalid network mask');
}

$this->mask = sprintf('%032b', ip2long(long2ip(~(2 ** (32 - (int) $parts[1]) - 1))));
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/KeySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
use Respect\Validation\Validator;
Expand Down Expand Up @@ -106,7 +106,7 @@ private function extractKeyRelatedValidators(array $validators): array
}

if (!$validator instanceof ValidatorBuilder) {
throw new InvalidRuleConstructorException('You must provide only key-related rules');
throw new InvalidValidatorException('You must provide only key-related rules');
}

$keyRelatedValidators = array_merge(
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/LanguageCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Exceptions\MissingComposerDependencyException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
Expand Down Expand Up @@ -46,7 +46,7 @@ public function __construct(

$availableSets = ['alpha-2', 'alpha-3'];
if (!in_array($set, $availableSets, true)) {
throw new InvalidRuleConstructorException(
throw new InvalidValidatorException(
'"%s" is not a valid set for ISO 639-3 (Available: %s)',
$set,
$availableSets,
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/Phone.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Attribute;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumberUtil;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Exceptions\MissingComposerDependencyException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
Expand Down Expand Up @@ -66,7 +66,7 @@ public function __construct(string|null $countryCode = null, Countries|null $cou
$countries ??= new Countries();
$this->country = $countries->getByAlpha2($countryCode);
if ($this->country === null) {
throw new InvalidRuleConstructorException('Invalid country code %s', $countryCode);
throw new InvalidValidatorException('Invalid country code %s', $countryCode);
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/Validators/PostalCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Validators\Core\Envelope;

Expand Down Expand Up @@ -42,7 +42,7 @@ public function __construct(string $countryCode, bool $formatted = false)
{
$countryCodeRule = new CountryCode();
if (!$countryCodeRule->evaluate($countryCode)->hasPassed) {
throw new InvalidRuleConstructorException('Cannot validate postal code from "%s" country', $countryCode);
throw new InvalidValidatorException('Cannot validate postal code from "%s" country', $countryCode);
}

parent::__construct(
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Attribute;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
use Respect\Validation\Validator;
Expand Down Expand Up @@ -55,7 +55,7 @@ public function __construct(
Validator $validator,
) {
if (!isset(self::DATA_STORAGE_UNITS[$unit])) {
throw new InvalidRuleConstructorException('"%s" is not a recognized data storage unit.', $unit);
throw new InvalidValidatorException('"%s" is not a recognized data storage unit.', $unit);
}

parent::__construct($validator);
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/Sorted.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
use Respect\Validation\Validator;
Expand Down Expand Up @@ -44,7 +44,7 @@ public function __construct(
private string $direction,
) {
if ($direction !== self::ASCENDING && $direction !== self::DESCENDING) {
throw new InvalidRuleConstructorException(
throw new InvalidValidatorException(
'Direction should be either "%s" or "%s"',
self::ASCENDING,
self::DESCENDING,
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/SubdivisionCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Exceptions\MissingComposerDependencyException;
use Respect\Validation\Helpers\CanValidateUndefined;
use Respect\Validation\Message\Template;
Expand Down Expand Up @@ -50,7 +50,7 @@ public function __construct(
$countries ??= new Countries();
$country = $countries->getByAlpha2($countryCode);
if ($country === null) {
throw new InvalidRuleConstructorException('"%s" is not a supported country code', $countryCode);
throw new InvalidValidatorException('"%s" is not a supported country code', $countryCode);
}

$this->country = $country;
Expand Down
4 changes: 2 additions & 2 deletions library/Validators/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Respect\Validation\Validators;

use Attribute;
use Respect\Validation\Exceptions\InvalidRuleConstructorException;
use Respect\Validation\Exceptions\InvalidValidatorException;
use Respect\Validation\Helpers\CanValidateDateTime;
use Respect\Validation\Message\Template;
use Respect\Validation\Result;
Expand All @@ -34,7 +34,7 @@ public function __construct(
private string $format = 'H:i:s',
) {
if (!preg_match('/^[gGhHisuvaA\W]+$/', $format)) {
throw new InvalidRuleConstructorException('"%s" is not a valid date format', $format);
throw new InvalidValidatorException('"%s" is not a valid date format', $format);
}
}

Expand Down
Loading