oxidecomputer / oxidecomputer/oxide.go
Validate enum types
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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