Skip to content

Commit

Permalink
add jalali_date_is_not_correct_with_different_default_character test
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Jun 2, 2024
1 parent cc3c720 commit f0046ec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Rules/ValidJalaliDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function passes($attribute, $value)

$date = explode($this->character, $value);

if (count($date) <= 1) {
return false;
}

return $this->checkValidDate(...$date);
}

Expand Down
15 changes: 15 additions & 0 deletions tests/Rules/ValidJalaliDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,19 @@ public function jalali_date_is_correct_with_different_default_character()
$this->assertTrue($passes);
}

/**
* Test jalali date is not correct with different default character.
*
* @test
*
* @return void
*/
public function jalali_date_is_not_correct_with_different_default_character()
{
$rules = ['jalali_date' => [new ValidJalaliDate('-')]];
$data = ['jalali_date' => '2016/15/25'];
$passes = $this->app['validator']->make($data, $rules)->passes();

$this->assertFalse($passes);
}
}

0 comments on commit f0046ec

Please sign in to comment.