@@ -622,6 +622,139 @@ public function testInputIsReplaced()
622622 $ this ->assertSame ('empty is not a valid email ' , $ v ->messages ()->first ('email ' ));
623623 }
624624
625+ public function testCapitalizedDisplayableValuesAreReplaced ()
626+ {
627+ // accepted_if
628+ $ trans = $ this ->getIlluminateArrayTranslator ();
629+ $ trans ->addLines (['validation.accepted_if ' => 'The :attribute field must be accepted when :Other is :Value. ' ], 'en ' );
630+ $ v = new Validator ($ trans , ['foo ' => 'no ' , 'bar ' => 'aaa ' ], ['foo ' => 'accepted_if:bar,aaa ' ]);
631+ $ this ->assertFalse ($ v ->passes ());
632+ $ v ->messages ()->setFormat (':message ' );
633+ $ this ->assertSame ('The foo field must be accepted when Bar is Aaa. ' , $ v ->messages ()->first ('foo ' ));
634+
635+ $ trans = $ this ->getIlluminateArrayTranslator ();
636+ $ trans ->addLines (['validation.accepted_if ' => 'The :attribute field must be accepted when :OTHER is :VALUE. ' ], 'en ' );
637+ $ v = new Validator ($ trans , ['foo ' => 'no ' , 'bar ' => 'aaa ' ], ['foo ' => 'accepted_if:bar,aaa ' ]);
638+ $ this ->assertFalse ($ v ->passes ());
639+ $ v ->messages ()->setFormat (':message ' );
640+ $ this ->assertSame ('The foo field must be accepted when BAR is AAA. ' , $ v ->messages ()->first ('foo ' ));
641+
642+ // in_array
643+ $ trans = $ this ->getIlluminateArrayTranslator ();
644+ $ trans ->addLines (['validation.in_array ' => 'The value of :attribute does not exist in :Other. ' ], 'en ' );
645+ $ v = new Validator ($ trans , ['foo ' => [1 , 2 , 3 ], 'bar ' => [1 , 2 ]], ['foo.* ' => 'in_array:bar.* ' ]);
646+ $ this ->assertSame ('The value of foo.2 does not exist in Bar.*. ' , $ v ->messages ()->first ('foo.2 ' ));
647+
648+ $ trans = $ this ->getIlluminateArrayTranslator ();
649+ $ trans ->addLines (['validation.in_array ' => 'The value of :attribute does not exist in :OTHER. ' ], 'en ' );
650+ $ v = new Validator ($ trans , ['foo ' => [1 , 2 , 3 ], 'bar ' => [1 , 2 ]], ['foo.* ' => 'in_array:bar.* ' ]);
651+ $ this ->assertSame ('The value of foo.2 does not exist in BAR.*. ' , $ v ->messages ()->first ('foo.2 ' ));
652+
653+ // missing_with
654+ $ trans = $ this ->getIlluminateArrayTranslator ();
655+ $ trans ->addLines (['validation.missing_with ' => 'The :attribute field must be missing when :Values is present. ' ], 'en ' );
656+ $ v = new Validator ($ trans , ['foo ' => [], 'bar ' => '2 ' ], ['foo ' => 'missing_with:baz,bar ' ]);
657+ $ this ->assertFalse ($ v ->passes ());
658+ $ this ->assertSame ('The foo field must be missing when Baz / Bar is present. ' , $ v ->errors ()->first ('foo ' ));
659+
660+ $ trans = $ this ->getIlluminateArrayTranslator ();
661+ $ trans ->addLines (['validation.missing_with ' => 'The :attribute field must be missing when :VALUES is present. ' ], 'en ' );
662+ $ v = new Validator ($ trans , ['foo ' => [], 'bar ' => '2 ' ], ['foo ' => 'missing_with:baz,bar ' ]);
663+ $ this ->assertFalse ($ v ->passes ());
664+ $ this ->assertSame ('The foo field must be missing when BAZ / BAR is present. ' , $ v ->errors ()->first ('foo ' ));
665+
666+ // present_with
667+ $ trans = $ this ->getIlluminateArrayTranslator ();
668+ $ trans ->addLines (['validation.present_with ' => 'The :attribute field must be present when :Values is present. ' ], 'en ' );
669+ $ v = new Validator ($ trans , ['bar ' => 2 , 'baz ' => 2 ], ['foo ' => 'present_with:bar,baz ' ]);
670+ $ this ->assertFalse ($ v ->passes ());
671+ $ this ->assertSame ('The foo field must be present when Bar / Baz is present. ' , $ v ->errors ()->first ('foo ' ));
672+
673+ $ trans = $ this ->getIlluminateArrayTranslator ();
674+ $ trans ->addLines (['validation.present_with ' => 'The :attribute field must be present when :VALUES is present. ' ], 'en ' );
675+ $ v = new Validator ($ trans , ['bar ' => 2 , 'baz ' => 2 ], ['foo ' => 'present_with:bar,baz ' ]);
676+ $ this ->assertFalse ($ v ->passes ());
677+ $ this ->assertSame ('The foo field must be present when BAR / BAZ is present. ' , $ v ->errors ()->first ('foo ' ));
678+
679+ // prohibits
680+ $ trans = $ this ->getIlluminateArrayTranslator ();
681+ $ trans ->addLines (['validation.prohibits ' => 'The :attribute field prohibits :Other being present. ' ], 'en ' );
682+ $ v = new Validator ($ trans , ['email ' => 'foo ' , 'emails ' => 'bar ' , 'email_address ' => 'baz ' ], ['email ' => 'prohibits:emails,email_address ' ]);
683+ $ this ->assertFalse ($ v ->passes ());
684+ $ this ->assertSame ('The email field prohibits Emails / Email address being present. ' , $ v ->messages ()->first ('email ' ));
685+
686+ $ trans = $ this ->getIlluminateArrayTranslator ();
687+ $ trans ->addLines (['validation.prohibits ' => 'The :attribute field prohibits :OTHER being present. ' ], 'en ' );
688+ $ v = new Validator ($ trans , ['email ' => 'foo ' , 'emails ' => 'bar ' , 'email_address ' => 'baz ' ], ['email ' => 'prohibits:emails,email_address ' ]);
689+ $ this ->assertFalse ($ v ->passes ());
690+ $ this ->assertSame ('The email field prohibits EMAILS / EMAIL ADDRESS being present. ' , $ v ->messages ()->first ('email ' ));
691+
692+ // required_if_accepted
693+ $ trans = $ this ->getIlluminateArrayTranslator ();
694+ $ trans ->addLines (['validation.required_if_accepted ' => 'The :attribute field is required when :Other is accepted. ' ], 'en ' );
695+ $ v = new Validator ($ trans , ['foo ' => 'yes ' , 'bar ' => '' ], ['bar ' => 'required_if_accepted:foo ' ]);
696+ $ this ->assertFalse ($ v ->passes ());
697+ $ this ->assertSame ('The bar field is required when Foo is accepted. ' , $ v ->messages ()->first ('bar ' ));
698+
699+ $ trans = $ this ->getIlluminateArrayTranslator ();
700+ $ trans ->addLines (['validation.required_if_accepted ' => 'The :attribute field is required when :OTHER is accepted. ' ], 'en ' );
701+ $ v = new Validator ($ trans , ['foo ' => 'yes ' , 'bar ' => '' ], ['bar ' => 'required_if_accepted:foo ' ]);
702+ $ this ->assertFalse ($ v ->passes ());
703+ $ this ->assertSame ('The bar field is required when FOO is accepted. ' , $ v ->messages ()->first ('bar ' ));
704+
705+ // required_unless
706+ $ trans = $ this ->getIlluminateArrayTranslator ();
707+ $ trans ->addLines (['validation.required_unless ' => 'The :attribute field is required unless :Other is in :Values. ' ], 'en ' );
708+ $ v = new Validator ($ trans , ['first ' => 'dayle ' , 'last ' => '' ], ['last ' => 'RequiredUnless:first,taylor,sven ' ]);
709+ $ this ->assertFalse ($ v ->passes ());
710+ $ this ->assertSame ('The last field is required unless First is in Taylor, Sven. ' , $ v ->messages ()->first ('last ' ));
711+
712+ $ trans = $ this ->getIlluminateArrayTranslator ();
713+ $ trans ->addLines (['validation.required_unless ' => 'The :attribute field is required unless :OTHER is in :VALUES. ' ], 'en ' );
714+ $ v = new Validator ($ trans , ['first ' => 'dayle ' , 'last ' => '' ], ['last ' => 'RequiredUnless:first,taylor,sven ' ]);
715+ $ this ->assertFalse ($ v ->passes ());
716+ $ this ->assertSame ('The last field is required unless FIRST is in TAYLOR, SVEN. ' , $ v ->messages ()->first ('last ' ));
717+
718+ // required_with
719+ $ trans = $ this ->getIlluminateArrayTranslator ();
720+ $ trans ->addLines (['validation.required_with ' => 'The :attribute field is required when :Values is present. ' ], 'en ' );
721+ $ v = new Validator ($ trans , ['first ' => 'Taylor ' , 'last ' => '' ], ['last ' => 'required_with:first ' ]);
722+ $ this ->assertFalse ($ v ->passes ());
723+ $ this ->assertSame ('The last field is required when First is present. ' , $ v ->messages ()->first ('last ' ));
724+
725+ $ trans = $ this ->getIlluminateArrayTranslator ();
726+ $ trans ->addLines (['validation.required_with ' => 'The :attribute field is required when :VALUES is present. ' ], 'en ' );
727+ $ v = new Validator ($ trans , ['first ' => 'Taylor ' , 'last ' => '' ], ['last ' => 'required_with:first ' ]);
728+ $ this ->assertFalse ($ v ->passes ());
729+ $ this ->assertSame ('The last field is required when FIRST is present. ' , $ v ->messages ()->first ('last ' ));
730+
731+ // same
732+ $ trans = $ this ->getIlluminateArrayTranslator ();
733+ $ trans ->addLines (['validation.same ' => 'The :attribute field must match :Other. ' ], 'en ' );
734+ $ v = new Validator ($ trans , ['foo ' => 'bar ' , 'baz ' => 'boom ' ], ['foo ' => 'Same:baz ' ]);
735+ $ this ->assertFalse ($ v ->passes ());
736+ $ this ->assertSame ('The foo field must match Baz. ' , $ v ->messages ()->first ('foo ' ));
737+
738+ $ trans = $ this ->getIlluminateArrayTranslator ();
739+ $ trans ->addLines (['validation.same ' => 'The :attribute field must match :OTHER. ' ], 'en ' );
740+ $ v = new Validator ($ trans , ['foo ' => 'bar ' , 'baz ' => 'boom ' ], ['foo ' => 'Same:baz ' ]);
741+ $ this ->assertFalse ($ v ->passes ());
742+ $ this ->assertSame ('The foo field must match BAZ. ' , $ v ->messages ()->first ('foo ' ));
743+
744+ // starts_with
745+ $ trans = $ this ->getIlluminateArrayTranslator ();
746+ $ trans ->addLines (['validation.starts_with ' => 'The :attribute must start with one of the following values :Values ' ], 'en ' );
747+ $ v = new Validator ($ trans , ['url ' => 'laravel.com ' ], ['url ' => 'starts_with:http,https ' ]);
748+ $ this ->assertFalse ($ v ->passes ());
749+ $ this ->assertSame ('The url must start with one of the following values Http, Https ' , $ v ->messages ()->first ('url ' ));
750+
751+ $ trans = $ this ->getIlluminateArrayTranslator ();
752+ $ trans ->addLines (['validation.starts_with ' => 'The :attribute must start with one of the following values :VALUES ' ], 'en ' );
753+ $ v = new Validator ($ trans , ['url ' => 'laravel.com ' ], ['url ' => 'starts_with:http,https ' ]);
754+ $ this ->assertFalse ($ v ->passes ());
755+ $ this ->assertSame ('The url must start with one of the following values HTTP, HTTPS ' , $ v ->messages ()->first ('url ' ));
756+ }
757+
625758 public function testInputIsReplacedByItsDisplayableValue ()
626759 {
627760 $ frameworks = [
0 commit comments