public function testValidateAttribute() { $val = new RegularExpressionValidator(['pattern' => '/^[a-zA-Z0-9](\\.)?([^\\/]*)$/m']); $m = FakedValidationModel::createWithAttributes(['attr_reg1' => 'b.4']); $val->validateAttribute($m, 'attr_reg1'); $this->assertFalse($m->hasErrors('attr_reg1')); $m->attr_reg1 = 'b./'; $val->validateAttribute($m, 'attr_reg1'); $this->assertTrue($m->hasErrors('attr_reg1')); }
/** * @param \yii\base\Model $model the data model to be validated * @param string $attribute the name of the attribute to be validated. */ protected function validateCharacters($model, $attribute) { if ($this->characters) { $this->validatorCharacters->validateAttribute($model, $attribute); } }