• D
    Validate multiple contexts on `valid?` and `invalid?` at once. · e3d99e23
    Dmitry Polushkin 提交于
    Example:
    
    ```ruby
    class Person
      include ActiveModel::Validations
    
      attr_reader :name, :title
      validates_presence_of :name, on: :create
      validates_presence_of :title, on: :update
    end
    
    person = Person.new
    person.valid?([:create, :update])    # => true
    person.errors.messages               # => {:name=>["can't be blank"], :title=>["can't be blank"]}
    ```
    e3d99e23
validations.rb 14.6 KB