public static function isValidNameError($name, $node = null)
    {
        self::invariant(is_string($name), 'Expected string');

        if (isset($name[1]) && $name[0] === '_' && $name[1] === '_') {
            return new Error(
                sprintf('Name "%s" must not begin with "__", which is reserved by ', $name) .
                'GraphQL introspection.',
                $node
            );
        }

        if (! preg_match('/^[_a-zA-Z][_a-zA-Z0-9]*$/', $name)) {
            return new Error(
                sprintf('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "%s" does not.', $name),
                $node
            );
        }

        return null;
    }
public static function isValidNameError($name, $node = null)
    {
        self::invariant(is_string($name), 'Expected string');

        if (isset($name[1]) && $name[0] === '_' && $name[1] === '_') {
            return new Error(
                sprintf('Name "%s" must not begin with "__", which is reserved by ', $name) .
                'GraphQL introspection.',
                $node
            );
        }

        if (! preg_match('/^[_a-zA-Z][_a-zA-Z0-9]*$/', $name)) {
            return new Error(
                sprintf('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "%s" does not.', $name),
                $node
            );
        }

        return null;
    }
Returns an Error if a name is invalid.

@param string    $name
@param Node|null $node

@return Error|null