Simply put your JSON Schema in and generate functions to validate them.
This is part of 'Even JSONB In PostgreSQL Needs Schemas' presented at POSETTE 2024, as is a work in progress.