File tree 2 files changed +31
-2
lines changed
2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use Illuminate \Contracts \Validation \Factory ;
6
6
use Illuminate \Contracts \Validation \Rule ;
7
+ use Laravel \Passport \Http \Rules \UriRule ;
7
8
8
9
class RedirectRule implements Rule
9
10
{
@@ -31,7 +32,7 @@ public function __construct(Factory $validator)
31
32
public function passes ($ attribute , $ value )
32
33
{
33
34
foreach (explode (', ' , $ value ) as $ redirect ) {
34
- $ validator = $ this ->validator ->make (['redirect ' => $ redirect ], ['redirect ' => ' url ' ]);
35
+ $ validator = $ this ->validator ->make (['redirect ' => $ redirect ], ['redirect ' => new UriRule ]);
35
36
36
37
if ($ validator ->fails ()) {
37
38
return false ;
@@ -46,6 +47,6 @@ public function passes($attribute, $value)
46
47
*/
47
48
public function message ()
48
49
{
49
- return 'One or more redirects have an invalid url format. ' ;
50
+ return 'One or more redirects have an invalid URI format. ' ;
50
51
}
51
52
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Laravel \Passport \Http \Rules ;
4
+
5
+ use Illuminate \Contracts \Validation \Rule ;
6
+
7
+ class UriRule implements Rule
8
+ {
9
+ /**
10
+ * {@inheritdoc}
11
+ */
12
+ public function passes ($ attribute , $ value ): bool
13
+ {
14
+ if (filter_var ($ value , FILTER_VALIDATE_URL )) {
15
+ return true ;
16
+ }
17
+
18
+ return false ;
19
+ }
20
+
21
+ /**
22
+ * {@inheritdoc}
23
+ */
24
+ public function message (): string
25
+ {
26
+ return 'The :attribute must be valid URI. ' ;
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments