aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools/validator.py
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/tools/validator.py')
-rw-r--r--mediagoblin/tools/validator.py26
1 files changed, 9 insertions, 17 deletions
diff --git a/mediagoblin/tools/validator.py b/mediagoblin/tools/validator.py
index 03598f9c..e8031a44 100644
--- a/mediagoblin/tools/validator.py
+++ b/mediagoblin/tools/validator.py
@@ -14,21 +14,15 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from wtforms.validators import Email, URL
+import six
def validate_email(email):
- """
- Validates an email
-
- Returns True if valid and False if invalid
"""
+ Validates an email
- email_re = Email().regex
- result = email_re.match(email)
- if result is None:
- return False
- else:
- return result.string
+ Returns True if valid and False if invalid
+ """
+ return '@' in email
def validate_url(url):
"""
@@ -36,11 +30,9 @@ def validate_url(url):
Returns True if valid and False if invalid
"""
-
- url_re = URL().regex
- result = url_re.match(url)
- if result is None:
+ try:
+ six.moves.urlparse(url)
+ return True
+ except Except as e:
return False
- else:
- return result.string