File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 3
3
namespace Wilsenhc \RifValidation \Rules ;
4
4
5
5
use Illuminate \Contracts \Validation \Rule ;
6
+ use Illuminate \Support \Str ;
6
7
7
8
class Rif implements Rule
8
9
{
@@ -40,6 +41,8 @@ public function passes($attribute, $value): bool
40
41
{
41
42
$ this ->attribute = $ attribute ;
42
43
44
+ $ value = Str::upper ($ value );
45
+
43
46
// Verificar si el RIF tiene el formato valido
44
47
if (!preg_match ('/^[VEPJGC]-?[\d]{8}-?[\d]$/i ' , $ value ))
45
48
{
Original file line number Diff line number Diff line change @@ -73,4 +73,23 @@ public function it_will_return_false_if_format_is_invalid()
73
73
74
74
$ this ->assertFalse ($ this ->rule ->passes ('rif ' , $ rif ));
75
75
}
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
+ }
76
95
}
You can’t perform that action at this time.
0 commit comments