mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-26 11:12:50 +00:00
fix: getattr directly
This commit is contained in:
@@ -4,7 +4,7 @@ from typing import Dict
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, model_validator
|
||||
|
||||
from openbb_core.provider.utils.validators import VALIDATORS
|
||||
from openbb_core.provider.utils import validators
|
||||
|
||||
|
||||
class QueryParams(BaseModel):
|
||||
@@ -24,7 +24,7 @@ class QueryParams(BaseModel):
|
||||
def _apply_validators(cls, values):
|
||||
for v, fields in cls.__validator_dict__.items():
|
||||
for f in fields:
|
||||
if f in values and (func := VALIDATORS.get(v)):
|
||||
if f in values and (func := getattr(validators, v)):
|
||||
values[f] = func(f, values[f])
|
||||
return values
|
||||
|
||||
|
||||
@@ -6,8 +6,5 @@ from typing import Optional
|
||||
def check_single(field: str, value: Optional[str]) -> Optional[str]:
|
||||
"""Check that string is a single value."""
|
||||
if value and ("," in value or ";" in value):
|
||||
raise ValueError(f"multiple values not allowed for field '{field}'")
|
||||
raise ValueError(f"multiple values not allowed for field '{field}'")
|
||||
return value
|
||||
|
||||
|
||||
VALIDATORS = {"check_single": check_single}
|
||||
|
||||
Reference in New Issue
Block a user