File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 44
55use Illuminate \Contracts \Validation \Factory ;
66use Illuminate \Contracts \Validation \Rule ;
7+ use Laravel \Passport \Http \Rules \UriRule ;
78
89class RedirectRule implements Rule
910{
@@ -31,7 +32,7 @@ public function __construct(Factory $validator)
3132 public function passes ($ attribute , $ value )
3233 {
3334 foreach (explode (', ' , $ value ) as $ redirect ) {
34- $ validator = $ this ->validator ->make (['redirect ' => $ redirect ], ['redirect ' => ' url ' ]);
35+ $ validator = $ this ->validator ->make (['redirect ' => $ redirect ], ['redirect ' => new UriRule ]);
3536
3637 if ($ validator ->fails ()) {
3738 return false ;
@@ -46,6 +47,6 @@ public function passes($attribute, $value)
4647 */
4748 public function message ()
4849 {
49- return 'One or more redirects have an invalid url format. ' ;
50+ return 'One or more redirects have an invalid URI format. ' ;
5051 }
5152}
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