I'm working with legacy a "Meta" field in a Model.
This field has not been documented or validated in the past, so it is being used everywhere without much of a structure.
Now I want to add a new field, and validate it, while not breaking older usages.
Think of:
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy import BaseModel
class Object(BaseModel):
#...
old_field = JSONB('old_field')
def set_old_field(self, inp: str):
self.old_field = inp
Now I want to add a foo field to the old_field, and I have a structure like such:
{"foo":
{
"settings":
{"color":"blue",
"position":"top"},
"active":false
}
}
How could I do it (maybe using pydantic), while allowing any other key but foo to pass without validation?