In Livewire I added a custom youtube video validation rule. It works very well, the problem is that I need it to be nullable and if I add in the validate nullable it gives me an error and I can’t find how to solve this problem.
Input:
<input wire:model="video" class="form-control" type="text" placeholder="Url youtube">
Rule:
public function passes($attribute, $value)
{
return (bool) preg_match('/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/',$value);
}
Validate:
'video' => 'nullable', new RuleYoutube,
Removing nullable works fine, but the field is not required. And with the nullable property I get the following error:
No property found for validation: [0]
Any suggestion? Thank you very much for spending time in my consultation