title: How to define CHECK constraint for a Postgres DOMAIN that is based on a composite type
body: <p>I would like to define a Postgres domain with check constraints based on a custom composite type.</p>
  <p>An example for a naive approach would be this:</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE TYPE raw_comp_foo AS (
      min_value    integer,
      max_value    integer
  );
  CREATE DOMAIN comp_foo AS raw_comp_foo
  CHECK (VALUE.min_value &lt; VALUE.max_value);
  
  </code></pre>
  <p>However, I get the error message <code>missing FROM-clause entry for table &quot;value&quot;</code>.
  How can I achieve the desired constraint in the example above?</p>