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

UUID validator regex is incorrect #96

Open
kostyay opened this issue Sep 9, 2020 · 0 comments
Open

UUID validator regex is incorrect #96

kostyay opened this issue Sep 9, 2020 · 0 comments

Comments

@kostyay
Copy link

kostyay commented Sep 9, 2020

The validator fails for a completely valid UUID 96733dad-7258-716b-22cb-e7963b266675.
Google parser parses it correctly, the generated validator does not.

The regex makes several incorrect assumptions, like hat the 3rd block must start with 4, which is not the case.

Code Sample:

package main

import (
	"fmt"
	"regexp"

	"github.com/google/uuid"
)

var _regex_GetApiTokenByClientIdRequest_ClientId = regexp.MustCompile(`^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[4][a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12})?$`)

func main() {


	guids := []string{"96733dad-7258-716b-22cb-e7963b266675", "89e20584-48b6-4b0b-9ce2-31e3d1125dad"}
	for _, g := range guids {
		_, err := uuid.Parse(g)
		fmt.Printf("v1: %s - %t\n", g, err == nil)
		a := _regex_GetApiTokenByClientIdRequest_ClientId.MatchString(g)
		fmt.Printf("v2: %s - %t\n", g, a)
	}
}
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