-
Notifications
You must be signed in to change notification settings - Fork 444
Fix for issue #50 Add regex validator to content_url #64
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
Conversation
…date tests to match
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.
we need the message to be configurable for potential reuse.
|
||
def property_matches(regex_to_match): | ||
|
||
COMPILED_RE = re.compile(regex_to_match) |
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.
This isn't a constant, so it should be compiled_re
@wraps(func) | ||
def validate_regex_decorator(self, value): | ||
if not COMPILED_RE.match(value): | ||
raise ValueError("content_url can contain only ascii letters, numbers, dashes, and underscores") |
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.
Make the message an argument that gets passed in because if we want to reuse this, then the error message would be wrong.
from .. import NAMESPACE | ||
|
||
|
||
VALID_CONTENT_URL_RE = r"^[a-zA-Z0-9_\-]*$" |
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.
Do we ever want the content url to be empty? I guess it is when we have the default site, right?
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.
Correct, it needs to validate "" or all of our models fail when reading responses from the default site
@@ -1,3 +1,5 @@ | |||
# coding=utf-8 |
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.
This should be part of our template for new files!
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.
🚀
…leau#64) * Bump test coverage up a bit in fields * Fix pep8 violation, and it fixed a few other things automatically as well
Content_urls can only be alphanumeric or underscores and dashes. Fix is to validate it client side because the Server error is confusing and the client should just prevent invalid urls from going through.