You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixelfed/app/Rules/ValidUrl.php

23 lines
551 B
PHTML

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