Automattic\WooCommerce\Vendor\GraphQL\Utils
Utils::isValidNameError
Returns an Error if a name is invalid.
Method of the class: Utils{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = Utils::isValidNameError( $name, ?Node $node ): ?Error;
- $name(string) (required)
- .
- ?Node $node
- .
Default:null
Utils::isValidNameError() Utils::isValidNameError code WC 11.1.2
public static function isValidNameError(string $name, ?Node $node = null): ?Error
{
if (isset($name[1]) && $name[0] === '_' && $name[1] === '_') {
return new Error(
"Name \"{$name}\" must not begin with \"__\", which is reserved by Automattic\WooCommerce\Vendor\GraphQL introspection.",
$node
);
}
if (preg_match('/^[_a-zA-Z][_a-zA-Z0-9]*$/', $name) !== 1) {
return new Error(
"Names must match /^[_a-zA-Z][_a-zA-Z0-9]*\$/ but \"{$name}\" does not.",
$node
);
}
return null;
}