function JsonApiSpec::isValidMemberName

Same name in other branches
  1. 8.9.x core/modules/jsonapi/src/JsonApiSpec.php \Drupal\jsonapi\JsonApiSpec::isValidMemberName()
  2. 10 core/modules/jsonapi/src/JsonApiSpec.php \Drupal\jsonapi\JsonApiSpec::isValidMemberName()
  3. 11.x 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.