def xid(instance, attribute, value):
     """
     Validator for xid attribute:
         * Type: Mandatory
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
 def ratetype(instance, attribute, value):
     """
     Validator for ratetype attribute:
         * Type: Mandatory
         * Format: S, R
         * Length: 1
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     if value not in ['S', 'R']:
         raise ValueError("{} must only 'S' or 'R'".format(attribute.name))
 def eci(instance, attribute, value):
     """
     Validator for eci attribute:
         * Type: Mandatory
         * Format: 0-9.
         * Length: 1
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length(attribute.name, value, 1)
     Validate.validate_regex(attribute.name, value, r'^[0-9]+$', 'numeric')
 def expdate(instance, attribute, value):
     """
     Validator for expdata (expiration date) attribute:
         * Type: Mandatory
         * Format: 0-9
         * Length: 4
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length(attribute.name, value, 4)
     Validate.validate_regex(attribute.name, value, r'^[0-9]+$', 'numeric')
Example #5
0
 def currency(instance, attribute, value):
     """
     Validator for currency attribute:
         * Type: Mandatory
         * Format: A-Z
         * Length: 3
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length(attribute.name, value, 3)
     Validate.validate_regex(attribute.name, value, r'^[A-Z]+$', 'uppercase alphanumeric')
Example #6
0
 def amount(instance, attribute, value):
     """
     Validator for amount attribute:
         * Type: Mandatory
         * Format: 0-9
         * Length: 1-11
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 11)
     Validate.validate_regex(attribute.name, value, r'^[0-9]+$', 'numeric')
 def number(instance, attribute, value):
     """
     Validator for card attribute:
         * Type: Mandatory
         * Format: 0-9
         * Length: 12-19
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 12, 19)
     Validate.validate_regex(attribute.name, value, r'^[0-9]+$', 'numeric')
 def rate(instance, attribute, value):
     """
     Validator for rate attribute:
         * Type: Mandatory
         * Format: 0-9.
         * Length: 1-6
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 6)
     Validate.validate_regex(attribute.name, value, r'^[0-9.]+$',
                             'numeric and .')
 def type(instance, attribute, value):
     """
     Validator for type attribute:
         * Type: Mandatory
         * Format: 1-5
         * Length: 1
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length(attribute.name, value, 1)
     Validate.validate_regex(attribute.name, value, r'^[1-5]+$',
                             'lower alphanumeric')
 def ccp(instance, attribute, value):
     """
     Validator for ccp attribute:
         * Type: Mandatory
         * Format: a-z
         * Length: 1-20
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 20)
     Validate.validate_regex(attribute.name, value, r'^[a-z]+$',
                             'lower alphanumeric')
 def chname(instance, attribute, value):
     """
     Validator for chname (card holder name) attribute:
         * Type: Mandatory
         * Format: a-zA-Z0-9-_
         * Length: 1-100
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 100)
     Validate.validate_regex(attribute.name, value, r'^[a-zA-Z0-9 \-\_]+$',
                             'alphanumeric and \-_ and spaces')
 def authcode(instance, attribute, value):
     """
     Validator for authcode attribute:
         * Type: Mandatory
         * Format: a-zA-Z0-9
         * Length: 1-10
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 10)
     Validate.validate_regex(attribute.name, value, r'^[a-zA-Z0-9]+$',
                             'alphanumeric')
Example #13
0
 def pares(instance, attribute, value):
     """
     Validator for pares attribute:
         * Type: Mandatory
         * Format: a-zA-Z0-9+/=
         * Length: 1-50
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 2000)
     Validate.validate_regex(attribute.name, value, r'^[a-zA-Z0-9\+\/\=]+$',
                             'alphanumeric and +/=')
 def type(instance, attribute, value):
     """
     Validator for type (VISA, MC, ...) attribute:
         * Type: Mandatory
         * Format: A-Z
         * Length: 1-15
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 15)
     Validate.validate_regex(attribute.name, value, r'^[A-Z]+$',
                             'uppercase alphanumeric')
 def ref(instance, attribute, value):
     """
     Validator for ref attribute:
         * Type: Mandatory
         * Format: a-zA-Z0-9-_
         * Length: 1-50
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 50)
     Validate.validate_regex(attribute.name, value, r'^[a-zA-Z0-9\-\_\.]+$',
                             'alphanumeric and -_.')
 def payer_exist(instance, attribute, value):
     """
     Validator for flag payer_exist, boolean but in XML are represented with '0' or '1'
         * Type: Mandatory
         * Format: True, False, 1, 0, '1', '0'
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     if instance.hpp_select_stored_card:
         if value not in [True, 1, '1']:
             raise ValueError("{} must only True, 1 or '1'".format(attribute.name))
     else:
         if value not in [False, 0, '0']:
             raise ValueError("{} must only False, 0, or '0'".format(attribute.name))
 def hpp_select_stored_card(instance, attribute, value):
     """
     Validator for pmt_ref attribute:
         * Type: Mandatory
         * Format: A-Za-z0-9_-\
         * Length: 0-30
     :param instance: object
     :param attribute:
     :param value:
     """
     Validate.validate_mandatory(attribute.name, value)
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 50)
     Validate.validate_regex(
         attribute.name,
         value,
         r'^[A-Za-z0-9\_\-\\ ]*$',
         'alphanumeric and _-\\ and spaces'
     )