Re-enabled the validator for for_id_random value missing. Probably for the 200th time... Made some changes so that it hopefully works correctly and does not break anything.

This commit is contained in:
Scott Idem
2024-08-09 16:01:15 -04:00
parent 394c2d1d94
commit 34dfea1379

View File

@@ -204,14 +204,14 @@ class Event_File_Base(BaseModel):
# NOTE: I kind of give up on this. Handling this outside of Pydantic and before the data is even attempted to be loaded into the Event_File_Base model. -STI 2021-09-10 # NOTE: I kind of give up on this. Handling this outside of Pydantic and before the data is even attempted to be loaded into the Event_File_Base model. -STI 2021-09-10
# NOTE: This validator will try to find and "set" the for_id_random value. However, The value is not really "set" in Pydantic. To get this value, exclude_unset=True when returning a dict from the model. # NOTE: This validator will try to find and "set" the for_id_random value. However, The value is not really "set" in Pydantic. To get this value, exclude_unset=True when returning a dict from the model.
# @validator('for_id_random', always=True) @validator('for_id_random', always=True)
# def for_id_random_lookup(cls, v, values, **kwargs): def for_id_random_lookup(cls, v, values, **kwargs):
# log.setLevel(logging.WARNING) log.setLevel(logging.WARNING)
# log.debug(locals()) log.debug(locals())
if isinstance(v, str): return v
# if values.get('for_id') and values['for_type']: elif values.get('for_id') and values['for_type']:
# return get_id_random(record_id=values['for_id'], table_name=values['for_type']) return get_id_random(record_id=values['for_id'], table_name=values['for_type'])
# return None return None
# @validator('for_id', always=True) # @validator('for_id', always=True)
# def for_id_lookup(cls, v, values, **kwargs): # def for_id_lookup(cls, v, values, **kwargs):