public function validate(Validatable $field) { if (!parent::validate($field) || !(round($field->getValue()) == $field->getValue())) { $field->setError('moet een geheel getal tussen ' . $this->min . ' en ' . $this->max . ' zijn'); return false; } return true; }
public function validateValue(Validatable $validateable) { $response = parent::validateValue($validateable); if ($response != null) { return $response; } if ($validateable->getValue() < $this->minimum) { $response = new ValidationResponse($this->getKeyName()); $response->addValue('min', $this->minimum); return $response; } }
public function __construct($min = false, $max = false, $int_len = '+', $dec_len = '+') { parent::__construct($min, $max); $this->int_len = $int_len; $this->dec_len = $dec_len; }
public function testValidateEmptyValue() { $v = new NumericValidator(); $this->assertTrue($v->validate('')); $this->assertTrue($v->validate(null)); }