Skip to content

Requiring validity of one or other tag on the same field #913

Answered by zemzale
ysomad asked this question in Q&A
Discussion options

You must be logged in to vote

Depends on what are the requirements for the username. But lets say its supposed to be only alphanumerics it would looks something like

type Req struct {
    Login string `validate:"required,email|alphanum"`
}

You can read more about other validations in docs
https://pkg.go.dev/github.com/go-playground/validator/v10#hdr-Using_Validator_Tags

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ysomad
Comment options

Answer selected by ysomad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants