def _validate_model(cls, data, context):
 errors = {}
 invalid_fields = []
 for (field_name, field) in iteritems(cls._fields):
  if ((field_name in cls._validator_functions) and (field_name in data)):
   value = data[field_name]
   try:
    cls._validator_functions[field_name](cls, data, value, context)
   except FieldError as exc:
    field = cls._fields[field_name]
    serialized_field_name = (field.serialized_name or field_name)
    errors[serialized_field_name] = exc.messages
    invalid_fields.append(field_name)
 for field_name in invalid_fields:
  data.pop(field_name)
 return errors

def _validate_model ( cls , data , context ) : errors = { } invalid_fields = [ ] for ( field_name , field ) in iteritems ( cls . _fields ) : if ( ( field_name in cls . _validator_functions ) and ( field_name in data ) ) : value = data [ field_name ] try : cls . _validator_functions [ field_name ] ( cls , data , value , context ) except FieldError as exc : field = cls . _fields [ field_name ] serialized_field_name = ( field . serialized_name or field_name ) errors [ serialized_field_name ] = exc . messages invalid_fields . append ( field_name ) for field_name in invalid_fields : data . pop ( field_name ) return errors
check that model and fitter are compatible and return a copy of the model .