Skip to content

Commit

Permalink
Add Null value support for RequiredUnless Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
BadJacky committed Aug 5, 2023
1 parent d6ad2e4 commit 8625bc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Attributes/Validation/RequiredUnless.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class RequiredUnless extends StringValidationAttribute implements RequiringRule
protected string|array $values;

public function __construct(
string|FieldReference $field,
array|string|BackedEnum|RouteParameterReference ...$values
string|FieldReference $field,
null|array|string|BackedEnum|RouteParameterReference ...$values
) {
$this->field = $this->parseFieldReference($field);
$this->values = Arr::flatten($values);
Expand Down
4 changes: 4 additions & 0 deletions tests/Datasets/Attributes/RulesDataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,10 @@ function requiredUnlessAttributes(): Generator
attribute: new RequiredUnless('field', 'key', 'other'),
expected: 'required_unless:field,key,other',
);
yield fixature(
attribute: new RequiredUnless('key', 'null'),
expected: 'required_unless:key,null',
);
}

function requiredWithAttributes(): Generator
Expand Down

0 comments on commit 8625bc6

Please sign in to comment.