Voluptuous supports custom validation functions [1], but they only receive as input parameter the value being currently validated, not any other previously validated values. This means trying to do something like 'bitrate': (lambda bitrate, resolution: Any(20, 16, 12, 8) if bitrate in (...) else Any (10, 8, 6, 4))
will unfortunately not work.
You can try using 'bitrate': Any(20, 16, 12, 10, 8, 6, 4)
and then performing secondary validation yourself to make sure it's consistent with resolution
.
Another approach could be to write a validator function for the complete dictionary, where the function would check both resolution
and bitrate
at the same time, though this way you'd be writing some code you normally get for free from voluptuous.
[1] https://github.com/alecthomas/voluptuous#validation-functions