title: Grails: Dynamically change domain's constraints in controller
body: <p>I'm a Grails beginner. I have a Domain class which has domainName field in Grails (ver. 2.0.1). In my DomainConstraints.groovy, I have:</p>
  
  <pre><code>constraints = {
      domainName blank: false, matches: "^([^.]{0,63}\\.)*([^.]{1,63})\$"
  }
  </code></pre>
  
  <p>but depending on some situation, i want to make this domainName field "blank: true" or "blank: false". I'm not validating my domain class against the actual database, so sync with the domain class and the actual table is not an issue.</p>
  
  <p>So, I want to do something like this (code below is from my imagination):</p>
  
  <pre><code>if(something){
     Domain.constraints.removeAttr('blank')
  } else {
     Domain.constraints.addAttr('blank', 'true')
  }
  </code></pre>
  
  <p>Is this possible?</p>