Skip to content

Commit 7a9bc7a

Browse files
tchsskraphael
andauthored
Add TooFewArgError to dsl.OneOf (#3577)
Co-authored-by: Raphael Simon <[email protected]>
1 parent df1919c commit 7a9bc7a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

dsl/attribute.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ func Field(tag any, name string, args ...any) {
219219
// })
220220
// })
221221
func OneOf(name string, args ...any) {
222+
if len(args) == 0 {
223+
eval.TooFewArgError()
224+
return
225+
}
222226
if len(args) > 2 {
223227
eval.TooManyArgError()
224228
return

eval/eval_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func TestTooFewArgError(t *testing.T) {
4242
"ErrorName": func() { ErrorName() },
4343
"ErrorName (int)": func() { Type("name", func() { ErrorName(1) }) },
4444
"Example": func() { Example() },
45+
"OneOf": func() { OneOf("name") },
4546
"Response (grpc)": func() { Service("s", func() { GRPC(func() { Response("name") }) }) },
4647
"Response (http)": func() { Service("s", func() { HTTP(func() { Response("name") }) }) },
4748
}

0 commit comments

Comments
 (0)