Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Validations

Dynamoid bakes in ActiveModel validations, just like ActiveRecord does.

class User
  include Dynamoid::Document

  # ...

  validates_presence_of :name
  validates_format_of :email, with: /@/
end

To see more usage and examples of ActiveModel validations, check out the ActiveModel validation documentation.

If you want to bypass model validation, pass validate: false to save call:

model.save(validate: false)