You are here

public function HCaptcha::getResponseErrors in hCaptcha 8

1 call to HCaptcha::getResponseErrors()
HCaptcha::validate in src/HCaptcha/HCaptcha.php

File

src/HCaptcha/HCaptcha.php, line 85

Class

HCaptcha

Namespace

Drupal\hcaptcha\HCaptcha

Code

public function getResponseErrors() {

  // Error code reference, https://hcaptcha.com/docs#server
  $errors = array();
  if (isset($this->validated->{'error-codes'}) && is_array($this->validated->{'error-codes'})) {
    $error_codes = $this
      ->getErrorCodes();
    foreach ($this->validated->{'error-codes'} as $code) {
      if (!isset($error_codes[$code])) {
        $code = 'unknown-error';
      }
      $errors[] = $error_codes[$code];
    }
  }
  return $errors;
}