#NEWLINE# def validate( self ) : #NEWLINE# #INDENT# 'Validate the value by the definition of the datatype.' #NEWLINE# if self . datatype . value_type : #NEWLINE# #INDENT# self . value = DataEntity . validate_datatype ( self . datatype . value_type , self . value , None , self . custom_def ) #NEWLINE# schema = Schema ( self . property_name , self . datatype . defs ) #NEWLINE# for constraint in schema . constraints : #NEWLINE# #INDENT# constraint . validate ( self . value ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not isinstance ( self . value , dict ) ) : #NEWLINE# #INDENT# ExceptionCollector . appendException ( TypeMismatchError ( what = self . value , type = self . datatype . type ) ) #NEWLINE# #UNINDENT# allowed_props = [ ] #NEWLINE# required_props = [ ] #NEWLINE# default_props = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if self . schema : #NEWLINE# #INDENT# allowed_props = self . schema . keys ( ) #NEWLINE# for ( name , prop_def ) in self . schema . items ( ) : #NEWLINE# #INDENT# if prop_def . required : #NEWLINE# #INDENT# required_props . append ( name ) #NEWLINE# #UNINDENT# if prop_def . default : #NEWLINE# #INDENT# default_props [ name ] = prop_def . default #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for value_key in list ( self . value . keys ( ) ) : #NEWLINE# #INDENT# if ( value_key not in allowed_props ) : #NEWLINE# #INDENT# ExceptionCollector . appendException ( UnknownFieldError ( what = ( _ ( 'Data value of type "%s"' ) % self . datatype . type ) , field = value_key ) ) #NEWLINE# #UNINDENT# #UNINDENT# for ( def_key , def_value ) in list ( default_props . items ( ) ) : #NEWLINE# #INDENT# if ( def_key not in list ( self . value . keys ( ) ) ) : #NEWLINE# #INDENT# self . value [ def_key ] = def_value #NEWLINE# #UNINDENT# #UNINDENT# missingprop = [ ] #NEWLINE# for req_key in required_props : #NEWLINE# #INDENT# if ( req_key not in list ( self . value . keys ( ) ) ) : #NEWLINE# #INDENT# missingprop . append ( req_key ) #NEWLINE# #UNINDENT# #UNINDENT# if missingprop : #NEWLINE# #INDENT# ExceptionCollector . appendException ( MissingRequiredFieldError ( what = ( _ ( 'Data value of type "%s"' ) % self . datatype . type ) , required = missingprop ) ) #NEWLINE# #UNINDENT# for ( name , value ) in list ( self . value . items ( ) ) : #NEWLINE# #INDENT# prop_schema = Schema ( name , self . _find_schema ( name ) ) #NEWLINE# DataEntity . validate_datatype ( prop_schema . type , value , prop_schema . entry_schema , self . custom_def ) #NEWLINE# if prop_schema . constraints : #NEWLINE# #INDENT# for constraint in prop_schema . constraints : #NEWLINE# #INDENT# if isinstance ( value , list ) : #NEWLINE# #INDENT# for val in value : #NEWLINE# #INDENT# constraint . validate ( val ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# constraint . validate ( value ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return self . value