Skip to content

Commit

Permalink
Remove null check from constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
vermakhushboo committed Dec 26, 2023
1 parent 0632306 commit f1a2fee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/Validator/Multiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@ class Multiple extends Validator
* Example:
*
* $multiple = new Multiple([$validator1, $validator2]);
* $multiple = new Multiple([$validator1, $validator2, $validator3], SELF::TYPE_STRING);
* $multiple = new Multiple([$validator1, $validator2, $validator3], self::TYPE_STRING);
*/
public function __construct(array $rules, ?string $type = null)
public function __construct(array $rules, ?string $type = self::TYPE_MIXED)
{
foreach ($rules as $rule) {
$this->addRule($rule);
}

if ($type !== null) {
$this->type = $type;
}
$this->type = $type;
}
/**
* Add rule
Expand Down
3 changes: 2 additions & 1 deletion tests/Validator/MultipleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ class MultipleTest extends TestCase

public function setUp(): void
{
$this->validator = new Multiple([new Text(20), new URL()]);
$this->validator = new Multiple([new Text(20), new URL()], Multiple::TYPE_STRING);
}

public function testIsValid()
{
$this->assertEquals('string', $this->validator->getType());
$this->assertEquals("1. Value must be a valid string and at least 1 chars and no longer than 20 chars \n2. Value must be a valid URL \n", $this->validator->getDescription());

// Valid URL but invalid text length
Expand Down

0 comments on commit f1a2fee

Please sign in to comment.