Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/Rule/AbstractRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function getMessageTemplate(): string
/**
* Validates a value
*/
abstract public function validate(mixed $value, string $valueIdentifier = null): bool;
abstract public function validate(mixed $value, ?string $valueIdentifier = null): bool;

/**
* Sets the error message prototype that will be used when
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Alpha.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Alpha extends AbstractRule
const MESSAGE = 'This input can contain only letters';
const LABELED_MESSAGE = '{label} can contain only letters';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$this->success = (bool)ctype_alpha((string)str_replace(' ', '', (string)$value));
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/AlphaNumHyphen.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AlphaNumHyphen extends AbstractRule
const MESSAGE = 'This input must contain only letters, digits, spaces, hyphens and underscores';
const LABELED_MESSAGE = '{label} must contain only letters, digits, spaces, hyphens and underscores';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$this->success = (bool)ctype_alnum(
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/AlphaNumeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AlphaNumeric extends AbstractRule

const LABELED_MESSAGE = '{label} must contain only letters and digits';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$this->success = (bool)ctype_alnum((string)str_replace(' ', '', $value));
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/ArrayLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ArrayLength extends AbstractRule
1 => self::OPTION_MAX
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$maxValidator = new ArrayMaxLength();
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/ArrayMaxLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ArrayMaxLength extends AbstractRule
self::OPTION_MAX
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!isset($this->options['max'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/ArrayMinLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ArrayMinLength extends AbstractRule
0 => self::OPTION_MIN
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!isset($this->options['min'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Between.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Between extends AbstractRule
1 => self::OPTION_MAX
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$minValidator = new LessThan();
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getUniqueId(): string
return $uniqueId;
}

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!isset($this->options['callback']) || !is_callable($this->options['callback'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Date extends AbstractRule
0 => self::OPTION_FORMAT
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$this->success = $value == date(
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Email extends AbstractRule

const LABELED_MESSAGE = '{label} must be a valid email address';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$this->success = (filter_var((string)$value, FILTER_VALIDATE_EMAIL) !== false);
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/EmailDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class EmailDomain extends AbstractRule
const MESSAGE = 'This the email address does not belong to a valid domain';
const LABELED_MESSAGE = '{label} does not belong to a valid domain';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$value = (string)$value;
$this->value = $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Equal.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Equal extends AbstractRule
0 => self::OPTION_VALUE
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (isset($this->options[self::OPTION_VALUE])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/File/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function setOption(string $name, mixed $value): static
return parent::setOption($name, $value);
}

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!file_exists($value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/File/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function setOption(string $name, mixed $value): static
return parent::setOption($name, $value);
}

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!file_exists($value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/File/ImageHeight.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ImageHeight extends AbstractRule
self::OPTION_MIN => 0,
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!file_exists($value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/File/ImageRatio.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function normalizeRatio(mixed $ratio): float
return 0;
}

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$ratio = RuleHelper::normalizeImageRatio($this->options[self::OPTION_RATIO]);
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/File/ImageWidth.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ImageWidth extends AbstractRule
self::OPTION_MIN => 0,
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!file_exists($value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/File/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Size extends AbstractRule
self::OPTION_SIZE => '2M'
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!file_exists($value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/FullName.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class FullName extends AbstractRule
/**
* This is not going to work with Asian names, http://en.wikipedia.org/wiki/Chinese_name.
*/
public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;

Expand Down
2 changes: 1 addition & 1 deletion src/Rule/GreaterThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GreaterThan extends AbstractRule
1 => self::OPTION_INCLUSIVE
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!isset($this->options['min'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/InList.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class InList extends AbstractRule
0 => self::OPTION_LIST
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!isset($this->options['list'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Integer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Integer extends AbstractRule
const MESSAGE = 'This input must be an integer number';
const LABELED_MESSAGE = '{label} must be an integer number';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$this->success = (bool)filter_var($value, FILTER_VALIDATE_INT) || $value === '0';
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/IpAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class IpAddress extends AbstractRule
const MESSAGE = 'This input is not a valid IP address';
const LABELED_MESSAGE = '{label} is not a valid IP address';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
// Do not allow private and reserved range IPs
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Length.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Length extends AbstractRule
2 => self::OPTION_ENCODING
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$maxValidator = new MaxLength();
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/LessThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LessThan extends AbstractRule
1 => self::OPTION_INCLUSIVE
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!isset($this->options['max'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Matching.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Matching extends AbstractRule
0 => self::OPTION_ITEM
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (isset($this->options[self::OPTION_ITEM])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/MaxLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MaxLength extends AbstractStringRule
1 => self::OPTION_ENCODING
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!isset($this->options['max'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/MinLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MinLength extends AbstractStringRule
1 => self::OPTION_ENCODING
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!isset($this->options['min'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/NotEqual.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class NotEqual extends Equal
const MESSAGE = 'This input is equal to {value}';
const LABELED_MESSAGE = '{label} is equal to {value}';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
parent::validate($value, $valueIdentifier);
$this->success = !$this->success;
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/NotInList.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NotInList extends InList
0 => self::OPTION_LIST
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!isset($this->options['list'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/NotMatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class NotMatch extends Matching
const MESSAGE = 'This input does match {item}';
const LABELED_MESSAGE = '{label} does match {item}';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
parent::validate($value, $valueIdentifier);
$this->success = !$this->success;
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/NotRegex.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class NotRegex extends Regex
const MESSAGE = 'This input should not match the regular expression {pattern}';
const LABELED_MESSAGE = '{label} Tshould not match the regular expression {pattern}';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
parent::validate($value, $valueIdentifier);
$this->success = !$this->success;
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Number extends AbstractRule
const MESSAGE = 'This input must be a number';
const LABELED_MESSAGE = '{label} must be a number';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$this->success = (bool)filter_var($value, FILTER_VALIDATE_FLOAT) || (string)$value === '0';
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Regex extends AbstractRule
0 => self::OPTION_PATTERN
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (isset($this->options['pattern'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Required.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Required extends AbstractRule
const MESSAGE = 'This field is required';
const LABELED_MESSAGE = '{label} is required';

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$this->success = ($value !== null && $value !== '');
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/RequiredWhen.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getItemRule(): ?AbstractRule
return $rule; // @phpstan-ignore-line
}

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;

Expand Down
2 changes: 1 addition & 1 deletion src/Rule/RequiredWith.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RequiredWith extends Required
0 => self::OPTION_ITEM
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;

Expand Down
2 changes: 1 addition & 1 deletion src/Rule/RequiredWithout.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RequiredWithout extends Required
0 => self::OPTION_ITEM
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;

Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Upload/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function setOption(string $name, mixed $value): static
return parent::setOption($name, $value);
}

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!is_array($value) || !isset($value['tmp_name'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Upload/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function setOption(string $name, mixed $value): static
return parent::setOption($name, $value);
}

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!is_array($value) || !isset($value['tmp_name'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Upload/ImageHeight.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ImageHeight extends AbstractRule
self::OPTION_MIN => 0,
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!is_array($value) || !isset($value['tmp_name'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Upload/ImageRatio.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ImageRatio extends AbstractRule
self::OPTION_ERROR_MARGIN => 0,
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
$ratio = RuleHelper::normalizeImageRatio($this->options[self::OPTION_RATIO]);
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/Upload/ImageWidth.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ImageWidth extends AbstractRule
self::OPTION_MIN => 0,
];

public function validate(mixed $value, string $valueIdentifier = null): bool
public function validate(mixed $value, ?string $valueIdentifier = null): bool
{
$this->value = $value;
if (!is_array($value) || !isset($value['tmp_name'])) {
Expand Down
Loading