Active Model Error
Represents one single error
Methods
- A
- D
- F
- M
- N
- S
Constants
CALLBACKS_OPTIONS | = | [:if, :unless, :on, :allow_nil, :allow_blank, :strict] |
MESSAGE_OPTIONS | = | [:message] |
Attributes
[R] | attribute | The attribute of |
[R] | base | The object which the error belongs to |
[R] | options | The options provided when calling +errors#add+ |
[R] | raw_type | The raw value provided as the second parameter when calling +errors#add+ |
[R] | type | The type of error, defaults to |
Class Public methods
new(base, attribute, type = :invalid, **options) Link
Instance Public methods
details() Link
Returns the error details.
error = ActiveModel::Error.new(person, :name, :too_short, count: 5)
error.details
# => { error: :too_short, count: 5 }
Also aliased as: detail
full_message() Link
Returns the full error message.
error = ActiveModel::Error.new(person, :name, :too_short, count: 5)
error.full_message
# => "Name is too short (minimum is 5 characters)"
match?(attribute, type = nil, **options) Link
See if error matches provided attribute
, type
, and options
.
Omitted params are not checked for a match.
message() Link
Returns the error message.
error = ActiveModel::Error.new(person, :name, :too_short, count: 5)
error.message
# => "is too short (minimum is 5 characters)"
strict_match?(attribute, type, **options) Link
See if error matches provided attribute
, type
, and options
exactly.
All params must be equal to Error's own attributes to be considered a strict match.