code: func validateResource(v, collection string) error {
  	// A resource must contain exactly three forward slashes.
  	parts := splitResource(v)
  	switch len(parts) {
  	case 0:
  		return errors.New("missing project component")
  	case 1:
  		return errors.New("missing project name")
  	case 2:
  		return errors.New("missing collection type")
  	case 3:
  		return errors.New("missing resource name")
  	case 4:
  		break
  	default:
  		return fmt.Errorf("too many components (%d) in resource name", len(parts))
  	}
  
  	switch {
  	case parts[0] != "projects":
  		return errors.New("first resource component must be 'projects'")
  	case parts[2] != collection:
  		return fmt.Errorf("third resource component must be '%s'", collection)
  	}
  
  	// Validate the resource name.
  	if err := validateResourceName(parts[3]); err != nil {
  		return err
  	}
  	return nil
  }
docs: // validateResource validates that a resource is well-formed.
  //
  // A resource is in the form:
  // projects/<project>/<collection>/<value>