>>> validate = Schema(Union({'type':'a', 'a_val':'1'},{'type':'b', 'b_val':'2'}, ... discriminant=lambda val, alt: filter( ... lambda v : v['type'] == val['type'] , alt))) >>> validate({'type':'a', 'a_val':'1'}) == {'type':'a', 'a_val':'1'} True >>> with raises(MultipleInvalid, "not a valid value for dictionary value @ data['b_val']"): ... validate({'type':'b', 'b_val':'5'}) ```discriminant({'type':'b', 'a_val':'5'}, [{'type':'a', 'a_val':'1'},{'type':'b', 'b_val':'2'}])``` is invoked Without the discriminant, the exception would be "extra keys not allowed @ data['b_val']" Nc