diff --git a/README.md b/README.md index bbfae25..6afcad7 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,7 @@ contain anything, specify it as `list`: ... raise AssertionError('MultipleInvalid not raised') ... except MultipleInvalid as e: ... exc = e ->>> str(exc) == "not a valid value" +>>> str(exc) == "not a valid value @ data[1]" True >>> schema([]) [] diff --git a/voluptuous/schema_builder.py b/voluptuous/schema_builder.py index d487018..6667023 100644 --- a/voluptuous/schema_builder.py +++ b/voluptuous/schema_builder.py @@ -228,7 +228,7 @@ def _compile(self, schema): return self._compile_object(schema) if isinstance(schema, collections.Mapping): return self._compile_dict(schema) - elif isinstance(schema, list) and len(schema): + elif isinstance(schema, list): return self._compile_list(schema) elif isinstance(schema, tuple): return self._compile_tuple(schema) @@ -551,6 +551,10 @@ def validate_sequence(path, data): # Empty seq schema, allow any data. if not schema: + if data: + raise er.MultipleInvalid([ + er.ValueInvalid('not a valid value', [value]) for value in data + ]) return data out = []