예제 #1
0
 def get_cc_rule(self, encoder):
     pattern = ESAPI.security_configuration().get_validation_pattern(
         "CreditCard")
     ccr = StringValidationRule("ccrule", encoder, pattern)
     ccr.set_maximum_length(CC_MAX_LENGTH)
     ccr.set_allow_none(False)
     return ccr
예제 #2
0
    def get_valid_input(self,
                        context,
                        input_,
                        type_,
                        max_length,
                        allow_none,
                        error_list=None):
        rvr = StringValidationRule(type_, self.encoder)
        pattern = ESAPI.security_configuration().get_validation_pattern(type_)
        if pattern is not None:
            rvr.add_whitelist_pattern(pattern)
        else:
            rvr.add_whitelist_pattern(type_)

        rvr.set_maximum_length(max_length)
        rvr.set_allow_none(allow_none)
        return rvr.get_valid(context, input_, error_list)