#NEWLINE# def clean( self , value ) : #NEWLINE# #INDENT# super ( HKPhoneNumberField , self ) . clean ( self ) #NEWLINE# if ( value in EMPTY_VALUES ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# value = re . sub ( '(\\(|\\)|\\s+|\\+)' , '' , force_text ( value ) ) #NEWLINE# m = hk_phone_digits_re . search ( value ) #NEWLINE# if ( not m ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'invalid' ] ) #NEWLINE# #UNINDENT# value = ( '%s-%s' % ( m . group ( 1 ) , m . group ( 2 ) ) ) #NEWLINE# for special in hk_special_numbers : #NEWLINE# #INDENT# if value . startswith ( special ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'disguise' ] ) #NEWLINE# #UNINDENT# #UNINDENT# prefix_found = map ( ( lambda prefix : value . startswith ( prefix ) ) , hk_phone_prefixes ) #NEWLINE# if ( not any ( prefix_found ) ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'prefix' ] ) #NEWLINE# #UNINDENT# return value