@@ -1899,6 +1899,29 @@ public function testValidateDistinct()
18991899 $ this ->assertEquals ('There is a duplication! ' , $ v ->messages ()->first ('foo.1 ' ));
19001900 }
19011901
1902+ public function testValidateDistinctForTopLevelArrays ()
1903+ {
1904+ $ trans = $ this ->getIlluminateArrayTranslator ();
1905+
1906+ $ v = new Validator ($ trans , ['foo ' , 'foo ' ], ['* ' => 'distinct ' ]);
1907+ $ this ->assertFalse ($ v ->passes ());
1908+
1909+ $ v = new Validator ($ trans , [['foo ' => 1 ], ['foo ' => 1 ]], ['* ' => 'array ' , '*.foo ' => 'distinct ' ]);
1910+ $ this ->assertFalse ($ v ->passes ());
1911+
1912+ $ v = new Validator ($ trans , [['foo ' => 'a ' ], ['foo ' => 'A ' ]], ['* ' => 'array ' , '*.foo ' => 'distinct:ignore_case ' ]);
1913+ $ this ->assertFalse ($ v ->passes ());
1914+
1915+ $ v = new Validator ($ trans , [['foo ' => [['id ' => 1 ]]], ['foo ' => [['id ' => 1 ]]]], ['* ' => 'array ' , '*.foo ' => 'array ' , '*.foo.*.id ' => 'distinct ' ]);
1916+ $ this ->assertFalse ($ v ->passes ());
1917+
1918+ $ v = new Validator ($ trans , ['foo ' , 'foo ' ], ['* ' => 'distinct ' ], ['*.distinct ' => 'There is a duplication! ' ]);
1919+ $ this ->assertFalse ($ v ->passes ());
1920+ $ v ->messages ()->setFormat (':message ' );
1921+ $ this ->assertEquals ('There is a duplication! ' , $ v ->messages ()->first ('0 ' ));
1922+ $ this ->assertEquals ('There is a duplication! ' , $ v ->messages ()->first ('1 ' ));
1923+ }
1924+
19021925 public function testValidateUnique ()
19031926 {
19041927 $ trans = $ this ->getIlluminateArrayTranslator ();
0 commit comments