Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. JsonApiSpec.php

function JsonApiSpec::isValidCustomQueryParameter

Checks whether the given custom query parameter name is valid.

A custom query parameter name must be a valid member name, with one additional requirement: it MUST contain at least one non a-z character.

Requirements:

  • it MUST contain at least one character.
  • it MUST contain only the allowed characters
  • it MUST start and end with a "globally allowed character"
  • it MUST contain at least none a-z (U+0061 to U+007A) character

It is RECOMMENDED that a hyphen (U+002D), underscore (U+005F) or capital letter is used (i.e. camelCasing).

Parameters

string $custom_query_parameter_name: A custom query parameter name to validate.

Return value

bool Whether the given query parameter is in compliance with the JSON:API specification.

See also

http://jsonapi.org/format/#query-parameters

1 call to JsonApiSpec::isValidCustomQueryParameter()
JsonApiRequestValidator::validateQueryParams in core/modules/jsonapi/src/EventSubscriber/JsonApiRequestValidator.php
Validates custom (implementation-specific) query parameter names.

File

core/modules/jsonapi/src/JsonApiSpec.php, line 142

Class

JsonApiSpec
Defines constants used for compliance with the JSON:API specification.

Namespace

Drupal\jsonapi

Code

public static function isValidCustomQueryParameter($custom_query_parameter_name) {
    return static::isValidMemberName($custom_query_parameter_name) && preg_match('/[^a-z]/u', $custom_query_parameter_name) === 1;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal