form = &$form; $this->field = $field; $this->type = $type; $this->message = $message; } /** * Check if field value is valid. * Default check is that field is either optional or not empty. * @return boolean */ function isValid() { return $this->type == 'optional' || trim($this->form->getData($this->field)) != ''; } /** * Check if field value is empty and optional. * @return boolean */ function isEmptyAndOptional() { return $this->type == 'optional' && trim($this->form->getData($this->field)) == ''; } /** * Get the field associated with the check. * @return string */ function getField() { return $this->field; } /** * Get the error message associated with a failed validation check. * @return string */ function getMessage() { return Locale::translate($this->message); } } ?>