def __setitem__(self, key, value): value = normalize_rulesset(value) self.validate({key: value}) self.schema[key] = value
def allow_unknown(self, value): if not (self.is_child or isinstance(value, (bool, ValidatedSchema))): value = normalize_rulesset(value) ValidatedSchema(self, {'allow_unknown': value}) self._config['allow_unknown'] = value
def test_normalization_of_generic_type_aliasses(origin_type, expected_rules, validator): assert normalize_rulesset({"type": origin_type}) == expected_rules validator.schema = {"foo": expected_rules} # tests schema validation