Revision #15 was created by grigori on Nov 25, 2019, 11:42:39 PM.
explanation added
Content
[...]
//now let's check if ID is taken
['id','unique','filter'=>function(\yii\db\Query $q){$q->where(['id'=>$this->getAttribute('id')]);}],
```
First rule is a validator for an input. Second rule is a filter preparing UUID to be written in a binary format and keeping the text form for output. Third one is a validator running a query over the binary value generated by a filter. Note: I wrote `$this->getAttribute('id')`, `$this->id` returns a text form.
We can write a query to validate data, not to save it.