/**
  * Validates the request
  *
  * - Nonce validity
  * - Honeypot
  * - Captcha
  * - Email address
  * - Lists (POST and options)
  * - Additional validation using a filter.
  *
  * @return bool
  */
 public function validate()
 {
     $validator = new MC4WP_Form_Validator($this->data);
     // validate nonce
     if (!$validator->validate_nonce()) {
         $this->message_type = 'invalid_nonce';
         return false;
     }
     // ensure honeypot was given but not filled
     if (!$validator->validate_honeypot()) {
         $this->message_type = 'spam';
         return false;
     }
     // check timestamp difference, token should be generated at least 2 seconds before form submit
     if (!$validator->validate_timestamp()) {
         $this->message_type = 'spam';
         return false;
     }
     // check if captcha was present and valid
     if (!$validator->validate_captcha()) {
         $this->message_type = 'invalid_captcha';
         return false;
     }
     // validate email
     if (!$validator->validate_email()) {
         $this->message_type = 'invalid_email';
         return false;
     }
     // validate selected or submitted lists
     if (!$validator->validate_lists($this->get_lists())) {
         $this->message_type = 'no_lists_selected';
         return false;
     }
     // run custom validation (using filter)
     $custom_validation = $validator->custom_validation();
     if ($custom_validation !== true) {
         $this->message_type = $custom_validation;
         return false;
     }
     // finally, return true
     return true;
 }
 /**
  * Validates the request
  *
  * - Nonce validity
  * - Honeypot
  * - Captcha
  * - Email address
  * - Lists (POST and options)
  * - Additional validation using a filter.
  *
  * @return bool
  */
 public function validate()
 {
     // check required fields
     $required_fields = $this->form->get_required_fields();
     foreach ($this->data as $field => $value) {
         // check required fields
         if (in_array($field, $required_fields) && empty($value)) {
             $this->status = 'required_field_missing';
             return false;
         }
     }
     $validator = new MC4WP_Form_Validator($this->config, $this->data);
     // validate nonce
     if (!$validator->validate_nonce()) {
         $this->status = 'invalid_nonce';
         return false;
     }
     // ensure honeypot was given but not filled
     if (!$validator->validate_honeypot()) {
         $this->status = 'spam';
         return false;
     }
     // check timestamp difference, token should be generated at least 2 seconds before form submit
     if (!$validator->validate_timestamp()) {
         $this->status = 'spam';
         return false;
     }
     // check if captcha was present and valid
     if (!$validator->validate_captcha()) {
         $this->status = 'invalid_captcha';
         return false;
     }
     // validate email
     if (!$validator->validate_email()) {
         $this->status = 'invalid_email';
         return false;
     }
     // validate selected or submitted lists
     if (!$validator->validate_lists($this->get_lists())) {
         $this->status = 'no_lists_selected';
         return false;
     }
     // run custom validation (using filter)
     $custom_validation = $validator->custom_validation();
     if ($custom_validation !== true) {
         $this->status = $custom_validation;
         return false;
     }
     // finally, return true
     return true;
 }