#NEWLINE# def clean( self , value , gender = None ) : #NEWLINE# #INDENT# super ( CZBirthNumberField , self ) . clean ( value ) #NEWLINE# if ( value in EMPTY_VALUES ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# match = re . match ( birth_number , value ) #NEWLINE# if ( not match ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'invalid_format' ] ) #NEWLINE# #UNINDENT# ( birth , id ) = ( match . groupdict ( ) [ 'birth' ] , match . groupdict ( ) [ 'id' ] ) #NEWLINE# if ( len ( id ) == 3 ) : #NEWLINE# #INDENT# return ( '%s' % value ) #NEWLINE# #UNINDENT# month = int ( birth [ 2 : 4 ] ) #NEWLINE# if ( ( not ( 1 <= month <= 12 ) ) and ( not ( 21 <= month <= 32 ) ) and ( not ( 51 <= month <= 62 ) ) and ( not ( 71 <= month <= 82 ) ) ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'invalid' ] ) #NEWLINE# #UNINDENT# day = int ( birth [ 4 : 6 ] ) #NEWLINE# if ( not ( 1 <= day <= 31 ) ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'invalid' ] ) #NEWLINE# #UNINDENT# modulo = ( int ( ( birth + id [ : 3 ] ) ) % 11 ) #NEWLINE# if ( ( modulo == int ( id [ ( - 1 ) ] ) ) or ( ( modulo == 10 ) and ( id [ ( - 1 ) ] == '0' ) ) ) : #NEWLINE# #INDENT# return ( '%s' % value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'invalid' ] )