/**
  * validate function.
  *
  * Validates the rule against an appropriate function.
  * 
  * @access public
  * @param mixed $value
  * @return void
  */
 public function validate($value)
 {
     switch ($this->rule) {
         case 'required':
             $this->valid = FormValidation::isRequired($value);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be empty';
             break;
         case 'equal_to':
             $this->valid = FormValidation::isEqualTo($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field must be equal to ' . $this->options;
             break;
         case 'less_than':
             $this->valid = FormValidation::isLessThan($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be greater than ' . ($this->options - 1);
             break;
         case 'greater_than':
             $this->valid = FormValidation::isGreaterThan($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be less than ' . ($this->options + 1);
             break;
         case 'between':
             $this->valid = FormValidation::isBetween($value, $this->options[0], $this->options[1]);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be less than ' . $this->options[0] . ' or greater than ' . $this->options[1];
             break;
         case 'shorter_than':
             $this->valid = FormValidation::isShorterThan($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be longer than ' . ($this->options - 1) . ' characters';
             break;
         case 'longer_than':
             $this->valid = FormValidation::isLongerThan($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be shorter than ' . ($this->options + 1) . ' characters';
             break;
         case 'length_between':
             $this->valid = FormValidation::isLengthBetween($value, $this->options[0], $this->options[1]);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be shorter than ' . $this->options[0] . ' or longer than ' . $this->options[1] . ' characters';
             break;
         case 'date':
             $this->valid = FormValidation::isDate($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid date';
             break;
         case 'numeric':
             $this->valid = FormValidation::isNumeric($value);
             $this->message = !empty($this->message) ? $this->message : 'Field must contain numbers only';
             break;
         case 'alphabetic':
             $this->valid = FormValidation::isAlphabetic($value);
             $this->message = !empty($this->message) ? $this->message : 'Field must contain letters only';
             break;
         case 'alphanumeric':
             $this->valid = FormValidation::isAlphaNumeric($value);
             $this->message = !empty($this->message) ? $this->message : 'Field must contain numbers and letters only';
             break;
         case 'email':
             $this->valid = FormValidation::isEmail($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid email';
             break;
         case 'website':
             $this->valid = FormValidation::isWebsite($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid website';
             break;
         case 'uri':
             $this->valid = FormValidation::isURI($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid URI';
             break;
         case 'postcode':
             $this->valid = FormValidation::isPostcode($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid postcode';
             break;
         case 'custom':
             $this->valid = FormValidation::checkCustomError($this->options);
             $this->message = !empty($this->message) ? $this->message : 'Error';
             break;
     }
 }