-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from Onemind-Services-LLC/dev
Release v0.3.3
- Loading branch information
Showing
3 changed files
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.core.exceptions import ValidationError | ||
|
||
__all__ = ('validate_comma_separated',) | ||
|
||
|
||
def validate_comma_separated(value): | ||
if not isinstance(value, str): | ||
raise ValidationError("This field requires a string of comma-separated values.") | ||
values = value.split(',') | ||
if any(not item.strip() for item in values): | ||
raise ValidationError("Each value should be non-empty and comma-separated without extra spaces.") | ||
|
||
return value |
This file contains 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