mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-26 11:12:50 +00:00
fix: update validator
This commit is contained in:
@@ -25,7 +25,7 @@ class QueryParams(BaseModel):
|
||||
for v, fields in cls.__validator_dict__.items():
|
||||
for f in fields:
|
||||
if f in values and (func := VALIDATORS.get(v)):
|
||||
values[f] = func(values[f])
|
||||
values[f] = func(f, values[f])
|
||||
return values
|
||||
|
||||
def model_dump(self, *args, **kwargs):
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def check_single(v: Optional[str]) -> Optional[str]:
|
||||
def check_single(field: str, value: Optional[str]) -> Optional[str]:
|
||||
"""Check that string is a single value."""
|
||||
if v:
|
||||
if "," in v or ";" in v:
|
||||
raise ValueError("multiple values not allowed")
|
||||
return v
|
||||
if value:
|
||||
if "," in value or ";" in value:
|
||||
raise ValueError(f"multiple values not allowed for field '{field}'")
|
||||
return value
|
||||
|
||||
|
||||
VALIDATORS = {"check_single": check_single}
|
||||
|
||||
Reference in New Issue
Block a user