title: Grails: how to set a meta-constraint on domain class property?
body: <p>I have a Contact class that belongs to a Subscription and I want to set a hypothetic readonly constraint on the subscription property, to be consumed in the scaffold templates.</p>
  
  <p>The class looks like</p>
  
  <pre><code>class Contact {
  
     static belongsTo = [subscription: Subscription]
  
     static constraints = {
       subscription(nullable: false, readonly: true) // hypothetic *readonly* constraint
       name(blank: false)
       email(blank: false, email: true)
     }
  
     Integer id
     String name
     String email
     String description
  }
  </code></pre>
  
  <p>I found <a href="http://grails.org/doc/latest/api/org/codehaus/groovy/grails/validation/ConstrainedProperty.html#addMetaConstraint%28java.lang.String,%20java.lang.Object%29" rel="nofollow">ConstrainedProperty.addMetaConstraint</a> method that "adds a meta constraints which is a non-validating informational constraint".</p>
  
  <p>How do I call it from within the Domain class?</p>
  
  <p>And how do I get the meta-constraint?</p>