Need anything more on #7383 ?

http://dev.rubyonrails.org/ticket/7383

I submitted the patch a while back and refed it to the original ticket
#3375. If I need to update this patch for any reason to get it
included please let me know.

Thank you,

Joe Noon

I know I’ve been aching for this one lately.

> http://dev.rubyonrails.org/ticket/7383
>
> I submitted the patch a while back and refed it to the original ticket
> #3375. If I need to update this patch for any reason to get it
> included please let me know.

What's the rationale for having two options? Perhaps we could
deprecate allow_nil and add an 'optional' argument? Or make all the
validations allow blank and require validates_presence_of to prevent
nil and blank inputs?

> > http://dev.rubyonrails.org/ticket/7383
> >
> > I submitted the patch a while back and refed it to the original ticket
> > #3375. If I need to update this patch for any reason to get it
> > included please let me know.

What's the rationale for having two options? Perhaps we could
deprecate allow_nil and add an 'optional' argument? Or make all the
validations allow blank and require validates_presence_of to prevent
nil and blank inputs?

Say you want to validate the length something, as well as its
presence, without throwing two error messages:

validates_presence_of :something
validates_length_of :something, :is => 5, :allow_nil => true

Which doesnt work because through a form, :something is "", not nil.

Which would lead you to:

validates_presence_of :something
validates_length_of :something, :is => 5,
                    :if => Proc.new { |r| !r.something.blank? }

Which is unecessarily ugly. Since we already have :allow_nil using
the #nil? logic, I think we should have :allow_blank using the
#blank? logic:

validates_presence_of :something
validates_length_of :something, :is => 5, :allow_blank => true

Been a while since I've visited this issue. I've just implemented
the above workaround until this patch is applied. But I'm pretty
sure that explanation is how I remember the issue.

Joe