File: //usr/local/rvm/gems/ruby-2.5.9/doc/activemodel-6.1.4.1/ri/ActiveModel/Errors/add-i.ri
U:RDoc::AnyMethod[iI"add:ETI"ActiveModel::Errors#add;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"0Adds a new error of +type+ on +attribute+. ;TI"?More than one error can be added to the same +attribute+. ;TI"<If no +type+ is supplied, <tt>:invalid</tt> is assumed.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [
I"person.errors.add(:name)
;TI"?# Adds <#ActiveModel::Error attribute=name, type=invalid>
;TI"Pperson.errors.add(:name, :not_implemented, message: "must be implemented")
;TI"G# Adds <#ActiveModel::Error attribute=name, type=not_implemented,
;TI"L options={:message=>"must be implemented"}>
;TI"
;TI"person.errors.messages
;TI"9# => {:name=>["is invalid", "must be implemented"]}
;T:@format0o;
; [I"=If +type+ is a string, it will be used as error message.;T@o;
; [I"HIf +type+ is a symbol, it will be translated using the appropriate ;TI"$scope (see +generate_message+).;T@o;
; [I"FIf +type+ is a proc, it will be called, allowing for things like ;TI"2<tt>Time.now</tt> to be used within an error.;T@o;
; [I"DIf the <tt>:strict</tt> option is set to +true+, it will raise ;TI"FActiveModel::StrictValidationFailed instead of adding the error. ;TI"D<tt>:strict</tt> option can also be set to any other exception.;T@o;; [I"6person.errors.add(:name, :invalid, strict: true)
;TI"?# => ActiveModel::StrictValidationFailed: Name is invalid
;TI"?person.errors.add(:name, :invalid, strict: NameIsInvalid)
;TI")# => NameIsInvalid: Name is invalid
;TI"
;TI"$person.errors.messages # => {}
;T;
0o;
; [I"E+attribute+ should be set to <tt>:base</tt> if the error is not ;TI"1directly associated with a single attribute.;T@o;; [I"4person.errors.add(:base, :name_or_email_blank,
;TI"8 message: "either name or email must be present")
;TI"person.errors.messages
;TI"<# => {:base=>["either name or email must be present"]}
;TI"person.errors.details
;TI"2# => {:base=>[{error: :name_or_email_blank}]};T;
0:
@fileI"lib/active_model/errors.rb;T:0@omit_headings_from_table_of_contents_below000[ I",(attribute, type = :invalid, **options);T@?FI"Errors;TcRDoc::NormalClass00