title: CHECK CONSTRAINT to validate a JSON field using a regular expression
body: <p>I know I can use a regular expression in a constraint to validate the contents of a field like</p>
  
  <pre><code>CONSTRAINT foo CHECK (column ~* 'regex')
  </code></pre>
  
  <p>I know I can do this even for a json column as I can grab specific attributes of it like</p>
  
  <pre><code>CONSTRAINT bar CHECK ((column-&gt;&gt;'attribute')...
  </code></pre>
  
  <p>But is there any way to ensure that the json data as a whole matches a specific pattern? I mean if I have a field in which let's say only an object of key-value pairs is allowed, I mean this:</p>
  
  <pre><code>{"key1": "value1", "key2": "value2"}
  </code></pre>
  
  <p>(keys with arbitrary names) Can I validate this with a constraint?</p>