Skip to content

Commit

Permalink
Update validator function name in examples to show that value must b… (
Browse files Browse the repository at this point in the history
…#3327)

* Update validator function name in  examples to show that value must be bar vs must contain a space

* Add md file in
  • Loading branch information
michaelriri committed Dec 8, 2021
1 parent d1a0145 commit 043d16b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/3327-michaelrios28.md
@@ -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`.
2 changes: 1 addition & 1 deletion docs/examples/models_errors2.py
Expand Up @@ -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"')

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/models_errors3.py
Expand Up @@ -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
Expand Down

0 comments on commit 043d16b

Please sign in to comment.