Beispiel #1
0
 def supplementary_data(instance, attribute, value):
     """
     Validator for supplementary_data attribute (this field can be a dictionary or a string):
         * Type: Optional
         * Format: a-zA-Z0-9{}'",+“”.-_&\/@!?%()*:£$&€#[]|= and spaces
         * Length: 0-60
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     try:
         Validate.validate_dict(attribute.name, value)
         # If value is a dict, convert keys and values to string
         value = ''.join(
             ['{0}{1}'.format(k, v) for k, v in six.iteritems(value)])
     except ValueError:
         Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, six.text_type(value), 0,
                                    255)
     Validate.validate_regex(
         attribute.name, value,
         r'^[a-zA-Z0-9 {}\'",+“”.\-\_&\\/@!?%()*:£$&€#\[\]\|=]*$',
         'alphanumeric and \'",+“”.-_&\\/@!?%()*:£$&€#[]|= and spaces')
Beispiel #2
0
 def merchant_id(instance, attribute, value):
     """
     Validator for merchant id:
         * Type: Mandatory
         * Format: a-zA-Z0-9
         * Length: 1-50
     :param instance: object
     :param attribute:
     :param 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')
Beispiel #3
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')
Beispiel #5
0
 def account(instance, attribute, value):
     """
     Validator for account:
         * Type: Optional
         * Format: a-zA-Z0-9
         * Length: 0-30
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 0, 30)
     Validate.validate_regex(attribute.name, value, r'^[a-zA-Z0-9]*$', 'alphanumeric')
Beispiel #6
0
 def order_id(instance, attribute, value):
     """
     Validator for timestamp:
         * Type: Mandatory (auto-generated)
         * Format: a-zA-Z0-9-_
         * Length: 1-40
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 1, 40)
     Validate.validate_regex(attribute.name, value, r'^[a-zA-Z0-9\-\_]+$', 'alphanumeric and -_')
 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 number(instance, attribute, value):
     """
     Validator for number attribute:
         * Type: Optional
         * Format: 0-9
         * Length: 3-4
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 3, 4)
     Validate.validate_regex(attribute.name, value, r'^[0-9]+$', 'numeric')
 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 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')
 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 .')
Beispiel #14
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 email(instance, attribute, value):
     """
     Validator for email attribute:
         * Type: Optional
         * Format: a-zA-Z0-9.@-_
         * Length: 0-50
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 0, 50)
     Validate.validate_regex(attribute.name, value,
                             r'^[a-zA-Z0-9\.@\-\_]*$',
                             'alphanumeric and .@-_')
 def surname(instance, attribute, value):
     """
     Validator for surname attribute:
         * Type: Optional
         * Format: a-zA-Z0-9 -_'".,+
         * Length: 1-50
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     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')
 def string_twenty(instance, attribute, value):
     """
     Validator for attributes that have a length of 20 characters:
         * Type: Optional
         * Format: a-zA-Z0-9 -_'".,+()
         * Length: 0-20
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 0, 20)
     Validate.validate_regex(attribute.name, value,
                             r'^[a-zA-Z0-9 \-\_\'\".,\+\(\)]*$',
                             'alphanumeric and \'\".,-_+() and spaces')
Beispiel #18
0
 def additional_info(instance, attribute, value):
     """
     Validator for additional_info attribute:
         * Type: Optional
         * Format: a-zA-Z0-9 “”.-_,+@
         * Length: 0-50
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 0, 50)
     Validate.validate_regex(attribute.name, value,
                             r'^[a-zA-Z0-9 “”.\-\_,+@]*$',
                             'alphanumeric and “”.-_,+@ and spaces')
Beispiel #19
0
 def billing_code(instance, attribute, value):
     """
     Validator for billing_code attribute:
         * Type: Optional
         * Format: a-zA-Z0-9 “”,.-|
         * Length: 0-60
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 0, 60)
     Validate.validate_regex(attribute.name, value,
                             r'^[a-zA-Z0-9 “”,.\-/|]*$',
                             'alphanumeric and “”,.-/| and spaces')
Beispiel #20
0
 def country(instance, attribute, value):
     """
     Validator for currency attribute:
         * Type: Optional
         * Format: a-zA-Z0-9“”,.-|
         * Length: 3
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 0, 50)
     Validate.validate_regex(attribute.name, value,
                             r'^[a-zA-Z0-9“”,.\-/|]*$',
                             'alphanumeric and “”,.-')
Beispiel #21
0
 def url(instance, attribute, value):
     """
     Validator for url attribute:
         * Type: Optional
         * Format: a-zA-Z0-9',+.-_&\/?%:$&#=
         * Length: 0-255
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 0, 255)
     Validate.validate_regex(attribute.name, value,
                             r'^[a-zA-Z0-9\',+.\-\_&\\/?%:$&#=]*$',
                             'alphanumeric and \',+.-_&\/?%:$&#=')
Beispiel #22
0
 def card_payment_button(instance, attribute, value):
     """
     Validator for card_payment_button attribute:
         * Type: Optional
         * Format: a-zA-Z0-9 “”,.-|
         * Length: 0-60
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 0, 25)
     Validate.validate_regex(
         attribute.name, value,
         r'^[a-zA-Z0-9\'",+“”.\-\_&\\/@!?%()*:£$&€#[]|=]*$',
         'alphanumeric and \'",+“”.-_&\\/@!?%()*:£$&€#[]|= ')
 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'
     )
Beispiel #24
0
 def payer_ref(instance, attribute, value):
     """
     Validator for payer_ref attribute
     (this field must be mandatory if card_storage_enable and payer_exist are True):
         * Type: Conditional
         * Format: A-Za-z0-9_-\\
         * Length: 0-50
     :param instance: object
     :param attribute:
     :param value:
     """
     if int(instance.card_storage_enable) == 1 and int(
             instance.payer_exist) == 1:
         if not value:
             raise ValueError(
                 "{} is mandatory because CARD_STORAGE_ENABLE and PAYER_EXIST are set to '1'"
                 .format(attribute.name))
     Validate.validate_str(attribute.name, value)
     Validate.validate_length_range(attribute.name, value, 0, 50)
     Validate.validate_regex(attribute.name, value, r'^[a-zA-Z0-9\-\_\.]*$',
                             'alphanumeric and _-.')
 def comment(name, value):
     """
     Validator for comment attribute:
         * Type:     Optional
         * Format:   a-zA-Z0-9 \'\",\+“”.\_\-&\\/@!?%()\*\:£$&€#\[\]|=\;
                     ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥
         * Length:   0-255
     :param name: string
     :param value:
     """
     if not value:
         return
     Validate.validate_str(name, value)
     Validate.validate_length_range(name, value, 0, 255)
     Validate.validate_regex(
         name, value,
         r'^[a-zA-Z0-9 \'\",\+“”.\_\-&\\/@!?%()\*\:£$&€#\[\]|=\;'
         r'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥]*$',
         'alphanumeric and \'",+“”.-_&\\/@!?%()*:£$&€#[]|='
         'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥ and spaces'
     )