Răsfoiți Sursa

Create ValidUrl.php

Daniel Supernault 11 luni în urmă
părinte
comite
78eb1c88d6
1 a modificat fișierele cu 21 adăugiri și 0 ștergeri
  1. 21 0
      app/Rules/ValidUrl.php

+ 21 - 0
app/Rules/ValidUrl.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Rules;
+
+use Closure;
+use Illuminate\Contracts\Validation\ValidationRule;
+
+class ValidUrl implements ValidationRule
+{
+    /**
+     * Run the validation rule.
+     *
+     * @param  \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString  $fail
+     */
+    public function validate(string $attribute, mixed $value, Closure $fail): void
+    {
+        if (!str_starts_with(strtolower($value), 'https://')) {
+            $fail('The :attribute must start with https://.');
+        }
+    }
+}