1 | <?php |
||
47 | class UniqueValidator implements ValidatorInterface |
||
48 | { |
||
49 | |||
50 | use AllowEmpty, |
||
51 | SkipOnError, |
||
52 | Messages, |
||
53 | OnScenario, |
||
54 | Safe; |
||
55 | |||
56 | /** |
||
57 | * @var string the document class name that should be used to |
||
58 | * look for the attribute value being validated. Defaults to null, meaning using |
||
59 | * the class of the object currently being validated. |
||
60 | * |
||
61 | * @see attributeName |
||
62 | * @since 1.0.8 |
||
63 | */ |
||
64 | public $className; |
||
65 | |||
66 | /** |
||
67 | * @var string the ActiveRecord class attribute name that should be |
||
68 | * used to look for the attribute value being validated. Defaults to null, |
||
69 | * meaning using the name of the attribute being validated. |
||
70 | * |
||
71 | * @see className |
||
72 | * @since 1.0.8 |
||
73 | */ |
||
74 | public $attributeName; |
||
75 | |||
76 | /** |
||
77 | * @var array additional query criteria. This will be combined with the condition |
||
78 | * that checks if the attribute value exists in the corresponding table column. |
||
79 | * This array will be used to instantiate a {@link Criteria} object. |
||
80 | * @since 1.0.8 |
||
81 | */ |
||
82 | public $criteria = []; |
||
83 | |||
84 | /** |
||
85 | * @Label('{attribute} "{value}" has already been taken') |
||
86 | * @var string |
||
87 | */ |
||
88 | public $msgTaken = ''; |
||
89 | |||
90 | /** |
||
91 | * Validates the attribute of the object. |
||
92 | * If there is any error, the error message is added to the object. |
||
93 | * @param AnnotatedInterface $model the object being validated |
||
94 | * @param string $attribute the attribute being validated |
||
95 | */ |
||
96 | 4 | public function isValid(AnnotatedInterface $model, $attribute) |
|
135 | |||
136 | } |
||
137 |