public function validate($value) { $result = parent::validate($value); if ($result) { if (floor($value) != $value) { $this->_setLastError('must be an integer'); $result = false; } } return $result; }
public function validate($value) { if (parent::validate($value)) { $parts = explode('.', $value); if (count($parts) > 2 || count($parts) == 2 && strlen($parts[1]) > $this->_decimalPlaces) { $this->_setLastError('must be a number to no more than ' . $this->_decimalPlaces . ' decimal places'); } else { return true; } } return false; }
/** * Validate an Integer Field * * Integers must be numerical and within the specific range. Any decimal component * is rounded off (does not generate any error as long as it is within range). * * @param string $data Field data * @return string This function may alter data before validating it, if so this is the result * @throws FieldException, FieldSizeException */ public function validate($data) { return intval(parent::validate($data)); }
/** * @param $fromPaper * @return \KataBank\Number */ public function read($fromPaper) { $number = $this->builder->build($fromPaper); $this->validator->validate($number); return $number; }