Hi
How do i use custom validation rules with livewire?
I have a field where the validation depends on the content of this field.
When content of this field begins with the char A the validation Rule A should be used.
When i use a request class and then use the Validator Instance and add those rules like this:
protected function getValidatorInstance() {
$validator = parent::getValidatorInstance();
$validator->sometimes(‘type’, [new TypeA], function ($input) {
if ($type== “A”) {
return true;
}
return false;
});
return $validator;
}
How do i add my custom Rule in livewire?
I cant add an object instance to the rules constant.
How do i proceed?
Thanks Tobi