File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 33namespace Wilsenhc \RifValidation \Rules ;
44
55use Illuminate \Contracts \Validation \Rule ;
6+ use Illuminate \Support \Str ;
67
78class Rif implements Rule
89{
@@ -40,6 +41,8 @@ public function passes($attribute, $value): bool
4041 {
4142 $ this ->attribute = $ attribute ;
4243
44+ $ value = Str::upper ($ value );
45+
4346 // Verificar si el RIF tiene el formato valido
4447 if (!preg_match ('/^[VEPJGC]-?[\d]{8}-?[\d]$/i ' , $ value ))
4548 {
Original file line number Diff line number Diff line change @@ -73,4 +73,23 @@ public function it_will_return_false_if_format_is_invalid()
7373
7474 $ this ->assertFalse ($ this ->rule ->passes ('rif ' , $ rif ));
7575 }
76+
77+ /** @test */
78+ public function it_will_convert_values_to_uppercase_before_testing ()
79+ {
80+ // Valid RIF of "Universidad de Carabobo"
81+ $ rif = 'g-20000041-4 ' ;
82+
83+ $ this ->assertTrue ($ this ->rule ->passes ('rif ' , $ rif ));
84+
85+ // Valid RIF of "Banesco Banco Universal"
86+ $ rif = 'j-07013380-5 ' ;
87+
88+ $ this ->assertTrue ($ this ->rule ->passes ('rif ' , $ rif ));
89+
90+ // Valid RIF of "Nicolas Maduro Moros"
91+ $ rif = 'v-05892464-0 ' ;
92+
93+ $ this ->assertTrue ($ this ->rule ->passes ('rif ' , $ rif ));
94+ }
7695}
You can’t perform that action at this time.
0 commit comments