Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why the items in oneof tag can't include comma. #1309

Open
2 tasks done
Beaelf opened this issue Aug 19, 2024 · 0 comments
Open
2 tasks done

why the items in oneof tag can't include comma. #1309

Beaelf opened this issue Aug 19, 2024 · 0 comments

Comments

@Beaelf
Copy link

Beaelf commented Aug 19, 2024

  • I have looked at the documentation here first?
  • I have looked at the examples provided that may showcase my question here?

Package version eg. v9, v10:

v10

Issue, Question or Enhancement:

I want to limit the status value only to be 'active' or 'active,inactive', but it return panic.

Code sample, to showcase or reproduce:

func TestOneof(t *testing.T) {
	type User struct {
		Status string `validate:"oneof='active' 'inactive,active'"`
	}
	user := User{
		Status: "inactive,active",
	}
	err := validator.New().Struct(user)
	fmt.Println(err)
}

result

=== RUN   TestOneof
--- FAIL: TestOneof (0.00s)
panic: Undefined validation function 'active'' on field 'Status' [recovered]
	panic: Undefined validation function 'active'' on field 'Status'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant