1 """ This module contains all our input validation functions """
2 from constants import MIN_VER_CODE_SIZE, MAX_VER_CODE_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)
15 def validate_key_id(key_id):
17 """ Validates an EVE key ID. throws ValidationError exception if
18 the format is invalid.
21 #TODO: anything else we can do to validate the api key?
23 # I don't know enough about the keyID yet. seems to be only
24 # numeric. The 2 I made were 705 and 706 respectively. I think
25 # they are just incrementing numbers. But I won't assume that
31 def validate_ver_code(ver_code):
33 """ Validates an EVE Online verification code, throws
34 ValidationError exception if the format is invalid.
38 # What we DO know about the verification code is that it has to be
39 # at least 20 digits and at most 64. Seems to be alphanumeric
43 if len(ver_code) < MIN_VER_CODE_SIZE or len(ver_code) > MAX_VER_CODE_SIZE:
44 raise ValidationError("Verification code must be from 20 to 64 "