How do I include record relationships in validation? Say I have a record defining a foreign key relationship which is set to required, such as:  

public function defineRelations()
{
    return [
        'type' =&gt; [
            static::BELONGS_TO,
            'Events_EventTypeRecord',
            'required' =&gt; true,
            'onDelete' =&gt; static::CASCADE
        ]
    ];
}


If I try to save the record with typeId not set I'll eventually get a database exception but the error won't show up if I call $record-&gt;validate().

How do I make a relationship fail validation?
Yii/Active Record won't do this by default.  You'd need to manually add an exists validation rule to the typeId attribute to get it to behave like you're looking for.