public static function JsonApiSpec::isValidCustomQueryParameter in JSON:API 8
Same name and namespace in other branches
- 8.2 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()
- CustomQueryParameterNamesAccessCheck::validate in src/
Access/ CustomQueryParameterNamesAccessCheck.php - Validates custom JSON API query parameters.
- JsonApiSpecTest::testIsValidCustomQueryParameter in tests/
src/ Unit/ JsonApiSpecTest.php - Provides test cases.
File
- src/
JsonApiSpec.php, line 132
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;
}