File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Vimeo \Laravel \Rules ;
3+
4+ use Illuminate \Contracts \Validation \Rule ;
5+ use Vimeo \Laravel \Facades \Vimeo ;
6+
7+ class VimeoVideoIdValidationRule implements Rule
8+ {
9+ /**
10+ * Determine if the validation rule passes.
11+ *
12+ * @param string $attribute
13+ * @param mixed $value
14+ * @return bool
15+ */
16+ public function passes ($ attribute , $ value )
17+ {
18+ // Make an API request to Vimeo to check if the video with the given ID exists.
19+ // Replace 'your-api-endpoint' with the actual API endpoint you want to use.
20+ $ response = Vimeo::request ('/videos/ ' .$ value , [], 'GET ' );
21+
22+ // Check if the response status is 200, indicating a successful request.
23+ return data_get ($ response , 'status ' ) === 200 ;
24+ }
25+
26+ /**
27+ * Get the validation error message.
28+ *
29+ * @return string
30+ */
31+ public function message ()
32+ {
33+ // Return a generic error message if the validation fails.
34+ return __ ('The :attribute format is invalid. ' );
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments