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

helper/validation: UUID -> IsUUID #297

Merged
merged 3 commits into from
Jan 15, 2020
Merged

helper/validation: UUID -> IsUUID #297

merged 3 commits into from
Jan 15, 2020

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Jan 15, 2020

Just a (nitpicky) patch to align the function name with others and clarify the purpose of the function a bit.

I would be also 👌 with IsUUID or ValidUUID, but the function name should IMO communicate that it's positive validation.

@radeksimko radeksimko requested a review from a team January 15, 2020 08:47
@katbyte
Copy link
Contributor

katbyte commented Jan 15, 2020

I personally would say IsUUID is ideal as the package name already conveys "validating" and we would end up with valid in there twice: validation.IsUUID vs validation.IsValidUUID

@radeksimko
Copy link
Member Author

No problem - I will change it @katbyte

// UUIDRegExp is a Regular Expression that can be used to validate UUIDs
var UUIDRegExp = 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}$")
// uuidRegExp is a Regular Expression that can be used to validate UUIDs
var uuidRegExp = 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}$")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was intentionally exported in case a developer ever wanted a regex pattern for UUID, even though we don't use it internally

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in my mind it's an implementation detail in the context of the validation package which is supposed to provide validation functions and anything exported is a liability for potential stability, so that's why I'm thinking that this gives us some headroom to move this around more easily without having to break anything/anyone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I should have made it more clear, that this regex actually ISN'T used in the implementation (the related function just uses go's native parser). I believe Katie just threw in the Regex if it provided value to developers looking to use the regex. I gave her the unofficial "yeah why not throw it in" so that is my bad. We might want to just delete it for now and publish it in a future release should there be demand for it (also maybe it doesn't belong in validation 🤔 )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also maybe it doesn't belong in validation

That's my thinking. It would be very difficult to maintain any stability guarantees, because it's essentially a constant, so every time you change it you break it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, let's just delete it for now and bring it up again if it's needed later. cc @katbyte

rename IsValidUUID to IsUUID
Copy link
Contributor

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test function name and the two print statements within it need to be updated otherwise LGTM 👍👌

As well as the comment above the validation function

@appilon appilon changed the title helper/validation: UUID -> IsValidUUID helper/validation: UUID -> IsUUID Jan 15, 2020
@appilon appilon merged commit 7b90253 into master Jan 15, 2020
@appilon appilon deleted the fix-uuid-check branch January 15, 2020 22:19
@ghost
Copy link

ghost commented Feb 15, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Feb 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants