예제 #1
0
 /**
  * @return FieldInterface
  */
 protected function validate()
 {
     $fieldName = $this->getName();
     $validation = Validator::validate([$fieldName => $this->getValue()], [$fieldName => $this->getValidationRules()]);
     $this->isValid = (bool) $validation->isSuccess();
     $this->validationErrors = (array) $validation->getErrors();
     return $this;
 }
 /**
  * @covers \nkm\RedsysVirtualPos\Validation\Validator::required
  * @dataProvider requiredInputProvider
  */
 public function testRequired($inputs, $expected)
 {
     $rules = array('test' => array('required'));
     $validation_result = \nkm\RedsysVirtualPos\Validation\Validator::validate($inputs, $rules);
     $this->assertEquals($expected, $validation_result->isSuccess());
 }
 /**
  * @covers \nkm\RedsysVirtualPos\Validation\Validator::alpha_numeric
  * @dataProvider alphaNumericInputProvider
  */
 public function testAlphaNumeric($inputs, $expected)
 {
     $rules = array('test' => array('alpha_numeric'));
     $validation_result = \nkm\RedsysVirtualPos\Validation\Validator::validate($inputs, $rules);
     $this->assertEquals($expected, $validation_result->isSuccess());
 }
 /**
  * @covers \nkm\RedsysVirtualPos\Validation\Validator::min_length
  * @dataProvider minLengthInputProvider
  */
 public function testMinLength($inputs, $rules, $expected)
 {
     $validation_result = \nkm\RedsysVirtualPos\Validation\Validator::validate($inputs, $rules);
     $this->assertEquals($expected, $validation_result->isSuccess());
 }