You are here

protected function CustomQueryParameterNamesAccessCheck::validate in JSON:API 8

Validates custom JSON API query parameters.

Parameters

string[] $json_api_params: The JSON API parameters.

Return value

bool Whether the parameter is valid.

1 call to CustomQueryParameterNamesAccessCheck::validate()
CustomQueryParameterNamesAccessCheck::access in src/Access/CustomQueryParameterNamesAccessCheck.php
Denies access when using invalid custom JSON API query parameter names.

File

src/Access/CustomQueryParameterNamesAccessCheck.php, line 45

Class

CustomQueryParameterNamesAccessCheck
Validates custom (implementation-specific) query parameter names.

Namespace

Drupal\jsonapi\Access

Code

protected function validate(array $json_api_params) {
  foreach (array_keys($json_api_params) as $query_parameter_name) {

    // Ignore reserved (official) query parameters.
    if (in_array($query_parameter_name, JsonApiSpec::getReservedQueryParameters())) {
      continue;
    }
    if (!JsonApiSpec::isValidCustomQueryParameter($query_parameter_name)) {
      return FALSE;
    }
  }
  return TRUE;
}