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 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 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 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 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 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 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')
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 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 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')
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 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 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 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 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 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')
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 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 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 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')
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 “”,.-')
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')
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')
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 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')
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 \',+.-_&\/?%:$&#=')
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 \'",+“”.-_&\\/@!?%()*:£$&€#[]|= ')