code: func ValidateObjectRef(ref *api.ObjectRef, v HashAlgoValidation) error {
  	if ref == nil {
  		return errors.Reason("the object ref is not provided").
  			Tag(grpcutil.InvalidArgumentTag).Err()
  	}
  
  	switch {
  	case ref.HashAlgo < 0:
  		return errors.Reason("bad negative hash algo").Tag(grpcutil.InvalidArgumentTag).Err()
  	case ref.HashAlgo == 0:
  		return errors.Reason("unspecified hash algo").Tag(grpcutil.InvalidArgumentTag).Err()
  	}
  
  	if err := checkIsHex(ref.HexDigest); err != nil {
  		return errors.Annotate(err, "invalid %s hex digest", ref.HashAlgo).
  			Tag(grpcutil.InvalidArgumentTag).Err()
  	}
  
  	if v {
  		if err := ValidateHashAlgo(ref.HashAlgo); err != nil {
  			return err
  		}
  		hexDigestLen := supportedAlgos[ref.HashAlgo].hexDigestLen
  		if len(ref.HexDigest) != hexDigestLen {
  			return errors.Reason("invalid %s digest: expecting %d chars, got %d", ref.HashAlgo, hexDigestLen, len(ref.HexDigest)).
  				Tag(grpcutil.InvalidArgumentTag).Err()
  		}
  	}
  
  	return nil
  }
docs: // ValidateObjectRef returns a grpc-annotated error if the given object ref is
  // invalid.
  //
  // If v is KnownHash, will verify the current version of the code understands
  // the hash algo. Otherwise (if v is AnyHash) will just validate that the hex
  // digest looks sane, and will accept any hash algo (even if the current code
  // doesn't understand it). This is useful when round-tripping ObjectRefs and
  // instance IDs through the (outdated) client code back to the server.
  //
  // Errors have InvalidArgument grpc code.