= ActiveModel::Validations ------------------------------------------------------------------------ = Includes: HelperMethods (from /home/chedong/.local/share/rdoc) ------------------------------------------------------------------------ = Extended by: (from /home/chedong/.local/share/rdoc) ActiveSupport::Concern ActiveModel::Naming ActiveModel::Callbacks ActiveModel::Translation HelperMethods (from /home/chedong/.local/share/rdoc) ------------------------------------------------------------------------ == Active Model Validations Provides a full validation framework to your objects. A minimal implementation could be: class Person include ActiveModel::Validations attr_accessor :first_name, :last_name validates_each :first_name, :last_name do |record, attr, value| record.errors.add attr, "starts with z." if value.start_with?("z") end end Which provides you with the full standard validation stack that you know from Active Record: person = Person.new person.valid? # => true person.invalid? # => false person.first_name = 'zoolander' person.valid? # => false person.invalid? # => true person.errors.messages # => {first_name:["starts with z."]} Note that ActiveModel::Validations automatically adds an errors method to your instances initialized with a new ActiveModel::Errors object, so there is no need for you to do this manually. ------------------------------------------------------------------------ = Instance methods: errors invalid? raise_validation_error valid? validate validate! validates_with validation_context = Attributes: attr_accessor validation_context
Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-27 16:34 @216.73.216.194
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)