alecthomas / alecthomas/voluptuous

Validation with multiple fields

オープン
#281 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
1.9k
フォーク
237
PR マージ指標
30日以内にマージされた PR はありません

説明

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),
})
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。