I want to validate a postgres json field such that every item in an array inside the json contains certain properties. For example, let's say I have a json field which contains an array of objects contacts, I want each object in contacts always have a name and phone property. Like the following-
{
"contacts": [
{ "name": "a", "phone": "123" },
{ "name": "b", "phone": "456" }
]
}
Is there a builtin way to validate this so that this format is always maintained on insert/update?