Flowdock

All of the following validations are defined in the class scope of the model that you’re interested in validating. They offer a more declarative way of specifying when the model is valid and when it is not. It is recommended to use these over the low-level calls to validate and validate_on_create when possible.

Constants

DEFAULT_VALIDATION_OPTIONS = { :on => :save, :allow_nil => false, :message => nil

ALL_RANGE_OPTIONS = [ :is, :within, :in, :minimum, :maximum ].freeze

Attributes

Show files where this module is defined (1 file)
Register or log in to add new notes.
June 12, 2009
1 thank

Conditions work for lower-level validate methods too

I don’t think this is mentioned in the docs anywhere, or else I couldn’t find it: Because validate, validate_on_create, and validate_on_update are ActiveSupport::Callbacks, their symbol forms support conditions just like validates_presence_of and company:

validate :permaname_must_be_unique, :if => :normal_entry?
validate_on_create :posted_at_must_be_valid_timestamp, :unless => Proc.new {|e| e.posted_at.nil? }
validate_on_update :title_must_not_contain_apostrophes, :if => :title_starts_with_a_b?