Email field validator with contains and multiple values

Hi!

I’m trying to validate an url type field with contains for multiple values:

'link' => ['required', 'contains' => ['instagram.com', 'facebook.com']],

But only the second value is filtered.

Like this :

'link' => ['required', 'contains' => [['instagram.com', 'facebook.com']]],

I have a PHP error.

Is it possible to give an array to contains for a required url?

Thanks!

No, as the describtion of the validator says, it

Checks if the given string contains the given value

Better use match with a pattern.

1 Like