mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
Update validator function name in examples to show that value must b… (#3327)
* Update validator function name in examples to show that value must be bar vs must contain a space * Add md file in
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Changed the validator method name in the [Custom Errors example](https://pydantic-docs.helpmanual.io/usage/models/#custom-errors) to more accurately describe what the validator is doing; changed from `name_must_contain_space` to ` value_must_equal_bar`.
|
||||
@@ -5,7 +5,7 @@ class Model(BaseModel):
|
||||
foo: str
|
||||
|
||||
@validator('foo')
|
||||
def name_must_contain_space(cls, v):
|
||||
def value_must_equal_bar(cls, v):
|
||||
if v != 'bar':
|
||||
raise ValueError('value must be "bar"')
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class Model(BaseModel):
|
||||
foo: str
|
||||
|
||||
@validator('foo')
|
||||
def name_must_contain_space(cls, v):
|
||||
def value_must_equal_bar(cls, v):
|
||||
if v != 'bar':
|
||||
raise NotABarError(wrong_value=v)
|
||||
return v
|
||||
|
||||
Reference in New Issue
Block a user