code: func validateNICForCreation(n *crimson.NIC) error {
  	switch {
  	case n == nil:
  		return status.Error(codes.InvalidArgument, "NIC specification is required")
  	case n.Name == "":
  		return status.Error(codes.InvalidArgument, "NIC name is required and must be non-empty")
  	case n.Machine == "":
  		return status.Error(codes.InvalidArgument, "machine is required and must be non-empty")
  	case n.Switch == "":
  		return status.Error(codes.InvalidArgument, "switch is required and must be non-empty")
  	case n.Switchport < 1:
  		return status.Error(codes.InvalidArgument, "switchport must be positive")
  	default:
  		// If hostname or IPv4 address is specified, require both.
  		if n.Hostname != "" || n.Ipv4 != "" {
  			if n.Hostname == "" {
  				return status.Errorf(codes.InvalidArgument, "if IPv4 is specified then hostname is required and must be non-empty")
  			}
  			if n.Ipv4 == "" {
  				return status.Errorf(codes.InvalidArgument, "if hostname is specified then IPv4 address is required and must be non-empty")
  			}
  			_, err := common.ParseIPv4(n.Ipv4)
  			if err != nil {
  				return status.Errorf(codes.InvalidArgument, "invalid IPv4 address %q", n.Ipv4)
  			}
  		}
  		_, err := common.ParseMAC48(n.MacAddress)
  		if err != nil {
  			return status.Errorf(codes.InvalidArgument, "invalid MAC-48 address %q", n.MacAddress)
  		}
  		return nil
  	}
  }
docs: // validateNICForCreation validates a NIC for creation.