/** * Short description of method evaluate * * @access public * @author Jehan Bihin, <*****@*****.**> * @param values * @return boolean */ public function evaluate($values) { $returnValue = (bool) false; if ($values == intval($values)) { $returnValue = parent::evaluate($values); } else { $returnValue = false; $this->setMessage(__('The value of this field must be an integer')); } return (bool) $returnValue; }
/** * Function returns list of errors in the delivery data. * @param array $data delivery data (uri=>value) * (evaluate {@link self::getEvaluatedParams()} raw data before) * @return array */ public function getErrors($data) { $data = $this->mapDeliveryProperties($data); $errors = array(); $notEmptyValidator = new \tao_helpers_form_validators_NotEmpty(); $numericValidator = new \tao_helpers_form_validators_Numeric(); if (!$notEmptyValidator->evaluate($data[TAO_DELIVERY_START_PROP])) { $errors[TAO_DELIVERY_START_PROP] = $notEmptyValidator->getMessage(); } if (!$notEmptyValidator->evaluate($data[TAO_DELIVERY_END_PROP])) { $errors[TAO_DELIVERY_END_PROP] = $notEmptyValidator->getMessage(); } if ($data[TAO_DELIVERY_END_PROP] < $data[TAO_DELIVERY_START_PROP]) { $errors[TAO_DELIVERY_START_PROP] = __('start date must be before end date'); } if (!$notEmptyValidator->evaluate($data[RDFS_LABEL])) { $errors[RDFS_LABEL] = $notEmptyValidator->getMessage(); } if (isset($data[TAO_DELIVERY_MAXEXEC_PROP]) && !$numericValidator->evaluate($data[TAO_DELIVERY_MAXEXEC_PROP])) { $errors[TAO_DELIVERY_MAXEXEC_PROP] = $numericValidator->getMessage(); } return $errors; }