Here's a code fragment from a Rails project I am working on:
if has_youtube && has_vimeo
record.errors.add(:video_link, type: 'A project cannot have videos from both YouTube and Vimeo')
return
end
if record.video_link.present?
record.errors.add(:video_link, message: "This doesn't look like a valid YouTube or Vimeo link. Please try again.")
else
record.errors.add(:video_link, :blank, message: 'You need to complete this field to register.')
end
The documentation for the ActiveRecord::Error class and the Active Record Validation Guide both explain message, but neither explain type. What is type, what impact does it have on validation errors, and where is it documented?