-
Notifications
You must be signed in to change notification settings - Fork 232
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: add StringIsEmpty, StringIsWhitespace, StringIsNotEmpty, StringIsNotWhitespace, StringIsBase64, UUID, UUIDOrEmpty #294
Conversation
cbd4193
to
cb19d7a
Compare
) | ||
|
||
// 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}$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 👍
helper/validation/uuid.go
Outdated
} | ||
|
||
// UUID is a ValidateFunc that ensures a string is empty or can be parsed as UUID | ||
func UUIDOrEmpty(i interface{}, k string) (warnings []string, errors []error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer encourage composition with validation.Any
.
validation.Any(validation.UUID, validation.StringIsEmpty)
I mentioned earlier it might be nice to add StringIsEmpty
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooo i like that
Co-Authored-By: appilon <apilon@hashicorp.com>
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. |
No description provided.