def is_valid_ssn(x): """Validates that the field is 3 digits, a hyphen, 2 digits, a hyphen, and 4 final digits only.""" #return True # speed up testing valid_ssn=re.compile(r'^\d{3}-\d{2}-\d{4}$') if not bool(re.match(valid_ssn,x)): validation_error("Write the Social Security Number like this: XXX-XX-XXXX") return True
def is_valid_ssn ( inputValue ): # I guess we'll include the dashes in the count isRightLength = len( inputValue ) == 11 if ( not isRightLength ): validation_error( "Write the Social Security Number like this: XXX-XX-XXXX" ) return isRightLength
def validate_cpf(value): # Docassemble only performs validation if the field is filled if not value: return True try: value = validators_br.cpf(value) except Exception as e: validation_error(str(e)) return True
def validate_cpf(value): # ao executar a entrevista o docassemble executa as validações # antes do usuario preencher o campo, # por isso só deve fazer a validação se o campo estiver preenchido if not value: return True # passando o valor do docassemble para a função de validação try: value = validators_br.cpf(value) except Exception as e: validation_error(str(e)) return True
def contains_spolek(x): x = x.lower() if "spolek" in x: return True elif "z.s." in x: return True elif "zapsaný spolek" in x: return True else: validation_error( 'Název spolku <strong>musí</strong> obsahovat "z.s.", "spolek", nebo "zapsaný spolek"' ) return
def is_multiple_of_four(x): if (1.0 * x / 4) != int(x / 4): validation_error("The number must be a multiple of four") return True
def is_valid_dob ( inputValue ): isRightLength = len( inputValue ) == 10 if ( not isRightLength): validation_error("Write your date of birth like this: XX/XX/XXXX") return isRightLength
def is_valid_zip ( inputValue ): isRightLength = len( inputValue ) == 5 if ( not isRightLength): validation_error("Write the zipcode with 5 numbers: XXXXX") return isRightLength