diff --git a/app/models/captioned_image.rb b/app/models/captioned_image.rb index 5b9f77e..ecfb950 100644 --- a/app/models/captioned_image.rb +++ b/app/models/captioned_image.rb @@ -2,6 +2,10 @@ class CaptionedImage < ActiveRecord::Base attr_accessible :source_image_id, :text_bottom, :text_top, :title belongs_to :source_image delegate :adoption_info_url, to: :source_image + validates :title, :text_top, :text_bottom, allow_blank: true, format: { + with: %r{\A[A-Za-z0-9 _-?!]\Z}, + message: 'Only letters, numbers, underscores, hyphens, question marks, and exclamation marks are allowed.' + } def image_url SimpleMemeCaptainClient.captioned_image_url(u: source_image.url,