You can create CHECK constraints involving JSON operations in postgres, which is the same way you'd enforce any constraint.