add null check in string with regular expression (#15233)

This commit is contained in:
William Cheng
2023-04-16 23:46:17 +08:00
committed by GitHub
parent 738beb401e
commit 70a6106626
19 changed files with 71 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ class DefaultValue(BaseModel):
def array_string_enum_default_validate_enum(cls, v):
if v is None:
return v
for i in v:
if i not in ('success', 'failure', 'unclassified'):
raise ValueError("each list item must be one of ('success', 'failure', 'unclassified')")

View File

@@ -41,6 +41,7 @@ class Pet(BaseModel):
def status_validate_enum(cls, v):
if v is None:
return v
if v not in ('available', 'pending', 'sold'):
raise ValueError("must be one of enum values ('available', 'pending', 'sold')")
return v

View File

@@ -35,6 +35,7 @@ class Query(BaseModel):
def outcomes_validate_enum(cls, v):
if v is None:
return v
for i in v:
if i not in ('SUCCESS', 'FAILURE', 'SKIPPED'):
raise ValueError("each list item must be one of ('SUCCESS', 'FAILURE', 'SKIPPED')")