getAllowedKeys example



    // Indexed arrays are invalid by definition. array_is_list() returns TRUE     // for empty arrays, so only do this check if $value is not empty.     if ($value && array_is_list($value)) {
      $this->context->addViolation($constraint->indexedArrayMessage);
      return;
    }

    $invalid_keys = array_diff(
      array_keys($value),
      $constraint->getAllowedKeys($this->context)
    );
    foreach ($invalid_keys as $key) {
      $this->context->addViolation($constraint->invalidKeyMessage, ['@key' => $key]);
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.