validator icon indicating copy to clipboard operation
validator copied to clipboard

[Bug]: validation of uuidv4 failed with valid uuidv4

Open hdr1210 opened this issue 1 year ago • 2 comments

What happened?

The validation of the a uuid failed with a valid v4 uuid.

https://go.dev/play/p/LUMbUHajvZX

Version

v10

Example Code

const uuidStr = "e3e70682-c209-4cac-629f-6fbed82c07cd"

type test struct {
	Uuid string `json:"uuid"               validate:"uuid4_rfc4122|uuid4"`
}

testVar := test{
	Uuid: uuidStr,
}

valid := validator.New()
err := valid.Struct(&testVar)
if err != nil {
	fmt.Printf("err: %+v\n", err)
	os.Exit(-1)
}

hdr1210 avatar Jun 13 '25 14:06 hdr1210

Hmm... Here is my version of the UUID v4 test: https://go.dev/play/p/b7oBGW6_i3i

@hdr1210 are you sure that uuidStr = "e3e70682-c209-4cac-629f-6fbed82c07cd" is uuid v4?

nodivbyzero avatar Jun 13 '25 17:06 nodivbyzero

Thanks for the quick reply. I found out that the google package validates the uuid as correct, but apparently this address is invalid. The first character in the fourth segment should be a 8 , 9 , a, b, c or d.

hdr1210 avatar Jun 16 '25 07:06 hdr1210