Sha256: defc4bb137ca1046a94ac47daaae06d1512626b9dd8249543c045b94cc906db4
Contents?: true
Size: 1011 Bytes
Versions: 23
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
23 entries across 23 versions & 1 rubygems