ExistValidator checks if the value being validated can be found in the table column specified by
the ActiveRecord class [[targetClass]] and the attribute [[targetAttribute]].
This validator is often used to verify that a foreign key contains a value
that can be found in the foreign table.
The following are examples of validation rules using this validator:
php
a1 needs to exist
['a1', 'exist']
a1 needs to exist, but its value will use a2 to check for the existence
['a1', 'exist', 'targetAttribute' => 'a2']
a1 and a2 need to exist together, and they both will receive error message
[['a1', 'a2'], 'exist', 'targetAttribute' => ['a1', 'a2']]
a1 and a2 need to exist together, only a1 will receive error message
['a1', 'exist', 'targetAttribute' => ['a1', 'a2']]
a1 needs to exist by checking the existence of both a2 and a3 (using a1 value)
['a1', 'exist', 'targetAttribute' => ['a2', 'a1' => 'a3']]