Method: ActiveModel::Error#match?

Defined in:
activemodel/lib/active_model/error.rb

#match?(attribute, type = nil, **options) ⇒ Boolean

See if error matches provided attribute, type, and options.

Omitted params are not checked for a match.

Returns:

  • (Boolean)


166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'activemodel/lib/active_model/error.rb', line 166

def match?(attribute, type = nil, **options)
  if @attribute != attribute || (type && @type != type)
    return false
  end

  options.each do |key, value|
    if @options[key] != value
      return false
    end
  end

  true
end