指定のパターンの日付の文字列かを判定。
以下の実行で、ダウンロードできます
$ git clone git@gist.github.com:cf9b3e9d622790c7d749e449bd3d851b.git tests/Unit/Validations/DateFormat
指定のパターンの日付の文字列かを判定。
以下の実行で、ダウンロードできます
$ git clone git@gist.github.com:cf9b3e9d622790c7d749e449bd3d851b.git tests/Unit/Validations/DateFormat
<?php | |
namespace Tests\Unit\Validations\DateFormat; | |
use Tests\TestCase; | |
use Validator; | |
class DateFormatTest extends TestCase | |
{ | |
/** | |
* @test | |
* @dataProvider provider_date_format | |
*/ | |
public function date_format($input, $expected) | |
{ | |
$v = Validator::make( | |
$input, | |
['field' => 'required|date|date_format:Y-m-d'] | |
); | |
$this->assertEquals($expected, $v->passes()); | |
} | |
public function provider_date_format() | |
{ | |
return [ | |
[['field' => '2018-01-01'], true], | |
[['field' => '1/1/18'], false], | |
]; | |
} | |
} |