Fix for issue #50 Add regex validator to content_url#64
Merged
t8y8 merged 2 commits intotableau:developmentfrom Oct 18, 2016
Merged
Fix for issue #50 Add regex validator to content_url#64t8y8 merged 2 commits intotableau:developmentfrom
t8y8 merged 2 commits intotableau:developmentfrom
Conversation
…date tests to match
graysonarts
suggested changes
Oct 18, 2016
Contributor
graysonarts
left a comment
There was a problem hiding this comment.
we need the message to be configurable for potential reuse.
|
|
||
| def property_matches(regex_to_match): | ||
|
|
||
| COMPILED_RE = re.compile(regex_to_match) |
Contributor
There was a problem hiding this comment.
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") |
Contributor
There was a problem hiding this comment.
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_\-]*$" |
Contributor
There was a problem hiding this comment.
Do we ever want the content url to be empty? I guess it is when we have the default site, right?
Collaborator
Author
There was a problem hiding this comment.
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 | |||
Contributor
There was a problem hiding this comment.
This should be part of our template for new files!
bryceglarsen
pushed a commit
to bryceglarsen/server-client-python
that referenced
this pull request
Dec 28, 2023
…leau#64) * Bump test coverage up a bit in fields * Fix pep8 violation, and it fixed a few other things automatically as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.