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: add StringIsEmpty, StringIsWhitespace, StringIsNotEmpty, StringIsNotWhitespace, StringIsBase64, UUID, UUIDOrEmpty #294

Merged
merged 13 commits into from
Jan 14, 2020

Conversation

katbyte
Copy link
Contributor

@katbyte katbyte commented Jan 14, 2020

No description provided.

@katbyte katbyte force-pushed the kt/add-azurerm-validators-1 branch from cbd4193 to cb19d7a Compare January 14, 2020 22:15
@katbyte katbyte changed the title validation: add StringIsEmpty, StringIsBase64, GUID, GUIDOrEmpty validation: add StringIsEmpty, StringIsBase64, UUID, UUIDOrEmpty Jan 14, 2020
helper/validation/strings.go Show resolved Hide resolved
)

// 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.

nice 👍

}

// 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) {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooo i like that

@katbyte katbyte changed the title validation: add StringIsEmpty, StringIsBase64, UUID, UUIDOrEmpty validation: add StringIsEmpty, StringIsWhitespace, StringIsNotEmpty, StringIsNotWhitespace, StringIsBase64, UUID, UUIDOrEmpty Jan 14, 2020
helper/validation/strings.go Outdated Show resolved Hide resolved
Co-Authored-By: appilon <apilon@hashicorp.com>
@appilon appilon merged commit 404d3af into master Jan 14, 2020
@appilon appilon deleted the kt/add-azurerm-validators-1 branch January 14, 2020 23:24
@ghost
Copy link

ghost commented Feb 14, 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 14, 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.

2 participants