<p>I have a basic ActiveRecord model in which i have two fields that i would like to validate. The requirement is that at least one of the fields must have a value. Both can have values, but at least one needs a value.</p>

<p>How do i express this with </p>

<pre><code>validates_presence_of 
</code></pre>

<p>statements? For example:</p>

<pre><code>validates_presence_of :main_file
validates_presence_of :alt_file
</code></pre>

<p>i don't want an error to be generated if only one of them is empty, only if both are empty. </p>

```
```
validates_presence_of :main_file, :if => Proc.new { |p| p.alt_file.blank? }
validates_presence_of :alt_file, :if => Proc.new { |p| p.main_file.blank? }
```
```