title: Validate model field: if value equals a key in a hash
body: <p>In an initializer I have a huge <strong>COUNTRY_CODES</strong> hash, with format: </p>
  
  <pre><code>{ :us =&gt; "United States, :de =&gt; "Germany" }
  </code></pre>
  
  <p>In my model I want to validate that the entered value is:</p>
  
  <ul>
  <li>present</li>
  <li>a key of my country code hash</li>
  </ul>
  
  <p>How do I apporach this?</p>
  
  <p>I can't use:</p>
  
  <pre><code>validates :country, :presence =&gt; true,
                      :inclusion =&gt; { :in =&gt; COUNTRY_CODES }
  </code></pre>
  
  <p>I've tried custom validators, but I get method errors when the value is nil, e.g. when I try to use value.to_sym, causing me to validate the validator and it becomes messy.</p>
  
  <p>Trying to figure out the most DRY and efficient way of doing this.</p>