Sha256: 09ce5f44bef64127d598c761f78f6c60b04371a5f999566ab445c98ab1e31931
Contents?: true
Size: 943 Bytes
Versions: 7
Compression:
Stored size: 943 Bytes
Contents
# frozen_string_literal: true module Decidim module System # A form object used to create organizations from the system dashboard. # class AdminForm < Form mimic :admin attribute :email, String attribute :password, String attribute :password_confirmation, String validates :email, presence: true validates :password, confirmation: true, presence: true, unless: :admin_exists? validates :password_confirmation, presence: true, unless: :admin_exists? validates :password, password: { email: :email } validate :email, :email_uniqueness private def email_uniqueness return unless Admin.where(email: email).where.not(id: id).any? errors.add(:email, I18n.t("models.admin.validations.email_uniqueness", scope: "decidim.system")) end def admin_exists? id.present? end end end end
Version data entries
7 entries across 7 versions & 1 rubygems