コード例 #1
0
 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')
コード例 #2
0
 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')
コード例 #3
0
 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')
コード例 #4
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')
コード例 #5
0
 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')
コード例 #6
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')
コード例 #7
0
 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')
コード例 #8
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'
     )