title: Grails - Cannot add a custom validator for a property in the domain class
body: <p>I am trying to add a custom validator for the String state, which should check if the string country is "usa", then the state should be "Other". If country is not "usa" and state is "other" then it should throw an error.</p>
  
  <p>Also, I would like to add a custom validator for country to do the same.</p>
  
  <p>Please find the code for my domain class below.</p>
  
  <pre><code>package symcadminidp
  
  import java.sql.Timestamp
  
  import groovy.transform.ToString
  
  @ToString
  class Account {
  
  static auditable = [ignore:['dateCreated','lastUpdated']]
  
  String organization
  String organizationUnit 
  String status
  String address1
  String address2
  String zipcode
  String state
  String country
  
  Timestamp dateCreated
  Timestamp lastUpdated
  
  Account(){
      status = "ENABLED"
  }
  
  
  static hasMany = [samlInfo: SAMLInfo, contacts: Contact]
  static mapping = {
      table 'sidp_account_t'
      id column: 'account_id', generator:'sequence', params:[sequence:'sidp_seq']
      contacts cascade:'all'
      accountId generator:'assigned'
  
      organization column:'org'
      organizationUnit column:'org_unit'
      zipcode column:'zip'
      dateCreated column:'date_created'
      lastUpdated column:'date_updated'
  }
  static constraints = {
      organization size: 1..100, blank: false
      organizationUnit size: 1..100, blank: false, unique: ['organization']
      //The organizationUnit must be unique in one organization 
      //but there might be organizationUnits with same name in different organizations, 
      //i.e. the organizationUnit isn't unique by itself.
      address1 blank:false
      zipcode size: 1..15, blank: false
      contacts nullable: false, cascade: true
      status blank:false
      //state ( validator: {val, obj -&gt;  if (obj.params.country.compareTocompareToIgnoreCase("usa")) return (! obj.params.state.compareToIgnoreCase("other"))})
          //it.country.compareToIgnoreCase("usa")) return (!state.compareToIgnoreCase("other"))}
  }
  }
  </code></pre>
  
  <p>When I tried adding the above commented out code, I got the following error:</p>
  
  <p>URI: /symcadminidp/account/index
  Class: groovy.lang.MissingPropertyException
  Message: No such property: params for class: symcadminidp.Account</p>
  
  <p>I am new to grails and groovy and would appreciate any help with this issue.</p>