alecthomas / alecthomas/voluptuous
Validation with multiple fields
- Lenguaje dominante
- Python
- Estrellas
- 1.9k
- Forks
- 237
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Is it possible to validate a field using information from a second field? For example to check if the object doesn't violate a compound key constraint? Here's an example of what I pretend to do:
```
def ClientExists(v):
if client_exists(v):
return v
else:
raise Invalid('Client does not exist')
def CodeIsValid(v):
# Check if (client_id, fraction_code) is unique
sch_addfraction = Schema({
Required('client_id') : All(Coerce(int), Range(min=1, max=10000), ClientExists),
Required('fraction_code') : All(str, Length(min=1, max=4), CodeIsValid),
})
```
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.