This project is archived and is in readonly mode.
validates_non_format_of - the converse of validates_format_of
Reported by Brennan Dunn | June 16th, 2008 @ 04:21 PM
Considering that there exists validates_inclusion_of/validates_exclusion_of, I figured it would be prudent to have the same relationship established for the format validations.
class Page < ActiveRecord::Base
validates_non_format_of :permalink, :with => /^admin/i
end
Comments and changes to this ticket
-
Brennan Dunn June 16th, 2008 @ 06:31 PM
Agreed. I wasn't feeling creative enough to come up with a decent method name ;-)
-
Pratik August 3rd, 2008 @ 02:52 PM
- Assigned user set to Pratik
- State changed from new to incomplete
- Tag set to activerecord, patch, tested
I don't think we need a new validation method here. Could just add a new key to validates_format_of
validates_format_of :permalink, :without => /admin/i
-
Elliot Winkler June 29th, 2009 @ 05:11 AM
I think
validates_format_of :permalink, :not => /admin/i
reads a bit better. We ended up patching Rails a while back to support this, so I've prepped this into a proper patch, complete with tests, which I've attached. -
CancelProfileIsBroken August 7th, 2009 @ 02:16 PM
- Tag changed from activerecord, patch, tested to activerecord, bugmash, patch, tested
-
Peer Allan August 10th, 2009 @ 02:08 AM
Verified that the patch does not apply to 2-3-stable or master. The patch would have to be manually redone for master due to the refactor to ActiveModel
-
Rizwan Reza August 10th, 2009 @ 03:56 AM
- Tag changed from activerecord, bugmash, patch, tested to activerecord, bugmash, patch
not reproducible
+1 I really like the feature.
I am having problems implementing this to current master. The file to implement this activerecord/lib/active_model/validations/format.rb.
-
Elliot Winkler August 10th, 2009 @ 02:38 PM
Are all validations in ActiveModel, is that how it works now?
-
Elliot Winkler August 10th, 2009 @ 02:47 PM
Also I believe Peer meant for the first patch to apply to 2-3-stable and the second to apply to master since I'm guessing ActiveModel has been finished out more in master.
-
Peer Allan August 10th, 2009 @ 03:18 PM
That is exactly right, Elliot. The refactor to ActiveModel meant 2 patches, one for 2-3-stable (the first one) and one for master (the second one).
-
Pratik August 10th, 2009 @ 03:26 PM
I don't think this belongs to 2.3. I've applied it to the master using :without option.
Thanks!
-
Repository August 10th, 2009 @ 03:29 PM
- State changed from incomplete to resolved
(from [cccb0e6b9327fb562b72007a012933c9c61a33fa]) Add validates_format_of :without => /regexp/ option [Elliot Winkler, Peer Allan]
[#430 state:resolved]
Example :
validates_format_of :subdomain, :without => /www|admin|mail/
Signed-off-by: Pratik Naik pratiknaik@gmail.com
http://github.com/rails/rails/commit/cccb0e6b9327fb562b72007a012933...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 430 validates_non_format_of - the converse of validates_format_of [#430 state:resolved]