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

extended title validation #389

Merged
merged 5 commits into from
Mar 1, 2016
Merged

extended title validation #389

merged 5 commits into from
Mar 1, 2016

Conversation

webratz
Copy link
Contributor

@webratz webratz commented Feb 23, 2016

This PR adds the option to have custom title validators, as the default one is often to restrictive (AWS allows more characters)
Also there are some new checks for IAM Objects which help you catching errors before you run the CF template.

# unset/None is also legal
if title and not valid_names.match(title):
# some objects allow more characters than others
if title and 'validate_title' in dir(self):
Copy link
Member

Choose a reason for hiding this comment

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

Does it maybe make more sense to do away with this logic and instead move the valid_names.match into a default validate_title method? It'd make this a bit cleaner. This would become:

if title:
    self.validate_title()

@webratz
Copy link
Contributor Author

webratz commented Mar 1, 2016

You are right, this is a nicer way to implement this. Updated the PR

if title and not valid_names.match(title):
raise ValueError('Name "%s" not alphanumeric' % title)
# try to validate the title if its there
if self.title is not None:
Copy link
Member

Choose a reason for hiding this comment

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

if self.title is more pythonic, and should do what you want here. Otherwise I think this is good to go.

@webratz
Copy link
Contributor Author

webratz commented Mar 1, 2016

updated

@phobologic
Copy link
Member

Awesome, thanks @webratz !

phobologic added a commit that referenced this pull request Mar 1, 2016
extended title validation
@phobologic phobologic merged commit 2afa223 into cloudtools:master Mar 1, 2016
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

Successfully merging this pull request may close these issues.

2 participants