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 comments(instance, attribute, value):
     """
     Validator for comments list. For each comment calls comment validator
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_list(attribute.name, value)
     for key, comment in enumerate(value):
         FieldsValidator.comment("{}{}".format(attribute.name, key),
                                 comment)
 def presind(instance, attribute, value):
     """
     Validator for presind (presence indicator) attribute:
         * Type: Optional
         * Format: 1-4
         * Length: 1
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_length(attribute.name, value, 1)
     Validate.validate_regex(attribute.name, value, r'^[1-4]+$', 'numeric')
Exemple #5
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')
 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 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')
Exemple #8
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')
Exemple #9
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 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')
 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 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')
Exemple #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 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 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 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 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 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 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'
     )
Exemple #21
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')
 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')
Exemple #23
0
 def timestamp(instance, attribute, value):
     """
     Validator for timestamp:
         * Type: Mandatory (auto-generated)
         * Format: 0-9
         * Length: 14
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length(attribute.name, value, 14)
     Validate.validate_regex(attribute.name, value, r'^[0-9]+$', 'numeric')
Exemple #24
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 -_')
Exemple #25
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')
 def code(instance, attribute, value):
     """
     Validator for code attribute:
         * Type: Optional
         * Format: a-zA-Z
         * Length: 2
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length(attribute.name, value, 2)
     Validate.validate_regex(attribute.name, value, r'^[a-zA-Z]+$',
                             'alphanumeric')
Exemple #27
0
 def sha1hash(instance, attribute, value):
     """
     Validator for sha1hash:
         * Type: Mandatory (auto-generated)
         * Format: a-f0-9
         * Length: 40
     :param instance: object
     :param attribute:
     :param value:
     """
     if not value:
         return
     Validate.validate_str(attribute.name, value)
     Validate.validate_length(attribute.name, value, 40)
     Validate.validate_regex(
         attribute.name, value, r'^[a-f0-9]*$', 'numeric and a-f characters'
     )
 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')
 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 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 .@-_')