code: def validate_key(obj_name, key):
      
      if re.search(r'^[$]|\.|\x00', key):
          error_str = ('Invalid key name "{}" in {} object. The '
                       'key name cannot contain characters '
                       '".", "$" or null characters').format(key, obj_name)
          raise ValidationError(error_str)
docs: Check if `key` contains ".", "$" or null characters.
  
         https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names
  
          Args:
              obj_name (str): object name to use when raising exception
              key (str): key to validated
  
          Returns:
              None: validation successful
  
          Raises:
              ValidationError: will raise exception in case of regex match.