/** * @param $attribute */ public function validatePassword($attribute) { if (empty($this->password)) { return; } $StringValidator = new StringValidator(['min' => 6]); $StringValidator->validateAttribute($this, 'password'); $CompareValidator = new CompareValidator(['compareAttribute' => 'password']); $CompareValidator->validateAttribute($this, 'repassword'); }
public function testValidateAttributeOperators() { $value = 55; foreach ($this->getOperationTestData($value) as $operator => $tests) { $val = new CompareValidator(['operator' => $operator, 'compareValue' => $value]); foreach ($tests as $test) { $model = new FakedValidationModel(); $model->attr_test = $test[0]; $val->validateAttribute($model, 'attr_test'); $this->assertEquals($test[1], !$model->hasErrors('attr_test')); } } }