oxidecomputer / oxidecomputer/oxide.go

Validate enum types

Open
#421 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement Go SDK
Dominant language
Go
Stars
26
Forks
6
Avg merge
5h 33m
Merged PRs (30d)
9

Description

Overview

Enum types often have specific values they can take. For example, DiskBackendType can only be "local" or "distributed". When receiving external input, it is useful to validate that a value is actually a valid enum variant, so the SDK could provide validation methods like:

func (v DiskBackendType) Valid() bool {
	switch v {
	case DiskBackendTypeLocal, DiskBackendTypeDistributed:
		return true
	}
	return false
}

Now users can just cast an input and have the SDK validate it:

t := oxide.DiskBackendType(input)
if !t.Valid() {
    return fmt.Errorf("invalid disk type")
}
Implementation details

No response

Anything else you would like to add?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the enum type definitions in the Go SDK and check whether existing validation patterns or tests cover similar values. Add validation methods for the enum variants described in the issue, then verify that known variants are accepted and unknown cast values are rejected across the affected enums.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.