You are here

public static function JsonApiSpec::isValidMemberName in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/src/JsonApiSpec.php \Drupal\jsonapi\JsonApiSpec::isValidMemberName()

Checks whether the given member name is valid.

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"

Parameters

string $member_name: A member name to validate.

Return value

bool Whether the given member name is in compliance with the JSON:API specification.

See also

http://jsonapi.org/format/#document-member-names

2 calls to JsonApiSpec::isValidMemberName()
JsonApiSpec::isValidCustomQueryParameter in core/modules/jsonapi/src/JsonApiSpec.php
Checks whether the given custom query parameter name is valid.
JsonApiSpecTest::testIsValidMemberName in core/modules/jsonapi/tests/src/Unit/JsonApiSpecTest.php
Ensures that member names are properly validated.

File

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

Class

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

Namespace

Drupal\jsonapi

Code

public static function isValidMemberName($member_name) {
  return preg_match(static::MEMBER_NAME_REGEXP, $member_name) === 1;
}