def validate_options(opts): """Validates and normalizes options passed in a MongoDB URI. Returns a new dictionary of validated and normalized options. :Parameters: - `opts`: A dict of MongoDB URI options. """ return dict([_validate(opt, val) for opt, val in iteritems(opts)])
def validate_options(opts, warn=False): """Validates and normalizes options passed in a MongoDB URI. Returns a new dictionary of validated and normalized options. If warn is False then errors will be thrown for invalid options, otherwise they will be ignored and a warning will be issued. :Parameters: - `opts`: A dict of MongoDB URI options. - `warn` (optional): If ``True`` then warnigns will be logged and invalid options will be ignored. Otherwise invalid options will cause errors. """ if warn: return get_validated_options(opts) else: return dict([_validate(opt, val) for opt, val in iteritems(opts)])