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:
@@ -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: 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)
|
||||
# def for_id_random_lookup(cls, v, values, **kwargs):
|
||||
# log.setLevel(logging.WARNING)
|
||||
# log.debug(locals())
|
||||
|
||||
# if values.get('for_id') and values['for_type']:
|
||||
# return get_id_random(record_id=values['for_id'], table_name=values['for_type'])
|
||||
# return None
|
||||
@validator('for_id_random', always=True)
|
||||
def for_id_random_lookup(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
if isinstance(v, str): return v
|
||||
elif values.get('for_id') and values['for_type']:
|
||||
return get_id_random(record_id=values['for_id'], table_name=values['for_type'])
|
||||
return None
|
||||
|
||||
# @validator('for_id', always=True)
|
||||
# def for_id_lookup(cls, v, values, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user