fix: getattr directly

This commit is contained in:
montezdesousa
2024-02-12 11:42:58 +00:00
parent aad97cd9ea
commit 7a89f199ed
2 changed files with 3 additions and 6 deletions

View File

@@ -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

View File

@@ -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}