code: def validate_ok_for_replace(replacement):
      
      validate_is_mapping("replacement", replacement)
      # Replacement can be {}
      if replacement and not isinstance(replacement, RawBSONDocument):
          first = next(iter(replacement))
          if first.startswith('$'):
              raise ValueError('replacement can not include $ operators')
docs: Validate a replacement document.