diff --git a/voluptuous/tests/tests.py b/voluptuous/tests/tests.py index acd6642..aaa260d 100644 --- a/voluptuous/tests/tests.py +++ b/voluptuous/tests/tests.py @@ -16,6 +16,13 @@ from voluptuous.util import u, Capitalize, Lower, Strip, Title, Upper +def test_new_required_test(): + schema = Schema({ + 'my_key': All(int, Range(1, 20)), + }, required=True) + assert_true(schema.required) + + def test_exact_sequence(): schema = Schema(ExactSequence([int, int])) try: diff --git a/voluptuous/validators.py b/voluptuous/validators.py index 0e0e1fc..9b0e030 100644 --- a/voluptuous/validators.py +++ b/voluptuous/validators.py @@ -197,10 +197,12 @@ def __init__(self, *validators, **kwargs): def __voluptuous_compile__(self, schema): self._compiled = [] + old_required = schema.required self.schema = schema for v in self.validators: schema.required = self.required self._compiled.append(schema._compile(v)) + schema.required = old_required return self._run def _run(self, path, value):