public static function JsonApiSpec::isValidCustomQueryParameter in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/src/JsonApiSpec.php \Drupal\jsonapi\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 compliane with the JSON:API specification.
See also
http://jsonapi.org/format/#query-parameters
2 calls to JsonApiSpec::isValidCustomQueryParameter()
- JsonApiRequestValidator::validateQueryParams in core/
modules/ jsonapi/ src/ EventSubscriber/ JsonApiRequestValidator.php - Validates custom (implementation-specific) query parameter names.
- JsonApiSpecTest::testIsValidCustomQueryParameter in core/
modules/ jsonapi/ tests/ src/ Unit/ JsonApiSpecTest.php - Provides test cases.
File
- core/
modules/ jsonapi/ src/ JsonApiSpec.php, line 143
Class
- JsonApiSpec
- Defines constants used for compliance with the JSON:API specification.
Namespace
Drupal\jsonapiCode
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;
}