1 """ This module contains all our input validation functions """
2 from constants import KEY_SIZE
4 class ValidationError(StandardError):
5 """ Exception that is raised if input validation fails
7 def __init__(self, message):
8 StandardError.__init__(self)
12 return repr(self.message)
16 def validate_api_key(api_key):
17 """ Validates an EVE api key. throws ValidationError exception if the
20 #TODO: anything else we can do to validate the api key?
22 if len(api_key) != KEY_SIZE:
23 raise ValidationError("API Key must be %s characters" % KEY_SIZE)
24 elif not api_key.isalnum():
25 raise ValidationError("API Key must only contain alphanumeric " +\
29 def validate_uid(uid):
30 """ Validates an EVE Online uid, throws ValidationError exception if the
33 #TODO: anything else we can do to validate the uid?
36 raise ValidationError("UID must be a number")
38 raise ValidationError("Missing UID")