validate(tag) {
    if (tag == null || tag === '') {
      return '';
    }

    tag = String(tag);
    if (!/^([a-z0-9]|[a-z0-9][-_a-z0-9]{0,61}[a-z0-9])$/g.test(tag)) {
      const validationMessage = 'Tags must be 1-63 characters, ' +
          'beginning and ending with a lowercase alphanumeric character ' +
          '([a-z0-9]) with dashes (-), underscores (_), and ' +
          'lowercase alphanumerics between.';
      throw new Error(`Invalid tag, "${tag}". ${validationMessage}`);
    }
    return tag;
  }
Throws an error if setting an invalid tag. Will return empty string for
null or undefined inputs.
@param {string|null|undefined} tag
@return {string} The validated tag.
@throws {!Error} If the tag does not match the valid format.