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

Validation failed url with required_without #1296

Open
2 tasks done
fooxlj07 opened this issue Jul 22, 2024 · 0 comments
Open
2 tasks done

Validation failed url with required_without #1296

fooxlj07 opened this issue Jul 22, 2024 · 0 comments

Comments

@fooxlj07
Copy link

fooxlj07 commented Jul 22, 2024

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

Package version v10:

Issue, Question or Enhancement:

Field Field1 string validate:"required_without=Field2"``,url, if this field1 is empty, and field2 is not, the validation is failed
Error: Key: 'Field1' Error:Field validation for 'Field1' failed on the 'url' tag

Code sample, to showcase or reproduce:

package main

import (
	"fmt"

	"github.com/go-playground/validator/v10"
)

func main() {
	validate := validator.New()

	s := struct {
		Field1 string `validate:"required_without=Field2,url"`
		Field2 string `validate:"required_without=Field1"`
	}{
		// Field1: "ampq:cd.com",
		Field2: "field1",
	}

	fmt.Println(validate.Struct(s))
}
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