alecthomas / alecthomas/voluptuous
"AtLeastOne" dict Key Validator
- Lenguaje dominante
- Python
- Estrellas
- 1.9k
- Forks
- 237
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I want to be able to create a Schema with this idea:
```
s = Schema({
AtLeastOne('onetwo', 'group1'): Any(1, 2, None),
AtLeastOne('threefour', 'group1'): Any(3, 4, None),
'abc': 'abc'})
>>> s({'abc': 'abc'})
AtLeastOneInvalid: 'group1' must specify at least one of ['onetwo', 'threefour']
>>> s({'onetwo': 3, 'abc': 'abc'})
MultipleInvalid: not a valid value for dictionary value @ data['onetwo']
>>> s({'onetwo': 2, 'abc': 'abc'})
{'onetwo': 2, 'abc': 'abc'}
>>> s({'threefour': 4, 'abc': 'abc'})
{'threefour': 4, 'abc': 'abc'}
>>> s({'onetwo': 1, 'threefour': 3, 'abc': 'abc'})
{'onetwo': 1, 'threefour': 3, 'abc': 'abc'}
```
This completes the functionality started with the addition of `Exclusive` and `Inclusive`.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.