renaming docs examples (#972)

* renaming docs examples

* tweaks
This commit is contained in:
Samuel Colvin
2019-11-07 14:40:44 +00:00
committed by GitHub
parent 1d3f7824ec
commit 17b5ff42c1
85 changed files with 86 additions and 84 deletions
+19
View File
@@ -0,0 +1,19 @@
from pydantic import BaseModel, PydanticValueError, ValidationError, validator
class NotABarError(PydanticValueError):
code = 'not_a_bar'
msg_template = 'value is not "bar", got "{wrong_value}"'
class Model(BaseModel):
foo: str
@validator('foo')
def name_must_contain_space(cls, v):
if v != 'bar':
raise NotABarError(wrong_value=v)
return v
try:
Model(foo='ber')
except ValidationError as e:
print(e.json())