Skip to content

Instantly share code, notes, and snippets.

@lotsofbytes
Last active October 6, 2018 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lotsofbytes/c348ac5685426a26d4c02444ba84c951 to your computer and use it in GitHub Desktop.
Save lotsofbytes/c348ac5685426a26d4c02444ba84c951 to your computer and use it in GitHub Desktop.
[バリデーション:in] #laravel #L55 #validation

バリデーション:in

入力値が、指定の値のセットに含まれることを判定。

laravel 5.5

gistの画面

以下の実行で、ダウンロードできます

$ git clone git@gist.github.com:c348ac5685426a26d4c02444ba84c951.git tests/Unit/Validations/In
<?php
namespace Tests\Unit\Validations\In;
use Tests\TestCase;
use Validator;
class InTest extends TestCase
{
/**
* @test
* @dataProvider provider_in
*/
public function in_test($input, $expected)
{
$v = Validator::make(
$input,
['field' => 'required|in:a,b']
);
$this->assertEquals($expected, $v->passes());
}
public function provider_in()
{
return [
[['field' => 'a'], true],
[['field' => 'c'], false],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment