Sha256: 54def5313ca09a3dc468be674cb8d118573abe71f5084e1b11c600a6f07cf4ab
Contents?: true
Size: 1011 Bytes
Versions: 50
Compression:
Stored size: 1011 Bytes
Contents
# frozen_string_literal: true module Decidim module Conferences module Admin # A form object used to create conference media link from the admin dashboard. class MediaLinkForm < Form include TranslatableAttributes mimic :conference_media_link translatable_attribute :title, String attribute :link, String attribute :date, Decidim::Attributes::LocalizedDate attribute :weight, Integer, default: 0 validates :title, :date, :link, presence: true validate :link_format def link return if super.blank? return "http://#{super}" unless super.match?(%r{\A(http|https)://}i) super end private def link_format return if link.blank? uri = URI.parse(link) errors.add :link, :invalid if !uri.is_a?(URI::HTTP) || uri.host.nil? rescue URI::InvalidURIError errors.add :link, :invalid end end end end end
Version data entries
50 entries across 50 versions & 1 rubygems