from . import calculation as calc
from . import compatible as compat


def validate(cnpj_number):
    """This function validates a CNPJ number.

    This function uses calculation package to calculate both digits
    and then validates the number.

    :param cnpj_number: a CNPJ number to be validated.  Only numbers.
    :type cnpj_number: string
    :return: Bool -- True for a valid number, False otherwise.

    """

    _cnpj = compat.clear_punctuation(cnpj_number)

    if (len(_cnpj) != 14 or
       len(set(_cnpj)) == 1):
        return False

    first_part = _cnpj[:12]
    second_part = _cnpj[:13]
    first_digit = _cnpj[12]
    second_digit = _cnpj[13]

    if (first_digit == calc.calculate_first_digit(first_part) and
       second_digit == calc.calculate_second_digit(second_part)):
        return True

    return False

@@ -64,16 +64,49 @@
 ompat%0A%0A%0A
+@compat.check_special_characters%0A
 def vali
@@ -506,17 +506,16 @@
 %0A    if 
-(
 len(_cnp
@@ -525,23 +525,16 @@
 != 14 or
-%0A      
  len(set
@@ -546,17 +546,16 @@
 j)) == 1
-)
 :%0A      
@@ -692,17 +692,16 @@
 %0A    if 
-(
 first_di
@@ -734,16 +734,25 @@
 t_digit(
+%0A        
 first_pa
@@ -757,20 +757,18 @@
 part
+%0A    
 ) and
-%0A      
  sec
@@ -820,17 +820,16 @@
 nd_part)
-)
 :%0A      

add check_special_character decorator to validate function and format file with black