Sha256: 956a5ceb405f9c827f5012b5e0330b4bb1829c33eb15555f68046fa8f019c97c
Contents?: true
Size: 786 Bytes
Versions: 3
Compression:
Stored size: 786 Bytes
Contents
# frozen_string_literal: true require "csv" module Decidim module Admin # A form object used to upload CSV to batch participatory space private users. # class ParticipatorySpacePrivateUserCsvImportForm < Form attribute :file attribute :user_name, String attribute :email, String validates :file, presence: true validate :validate_csv def validate_csv if file.present? CSV.foreach(file.path) do |email, user_name| errors.add(:user_name, :invalid) unless user_name.match?(UserBaseEntity::REGEXP_NAME) errors.add(:email, :taken) if context && context.current_organization && context.current_organization.admins.where(email: email).exists? end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems