Sha256: ad602a1e22f8ab6b225360eadf759f4fe946c012823159fe5445bf94a8032a1e
Contents?: true
Size: 487 Bytes
Versions: 58
Compression:
Stored size: 487 Bytes
Contents
# frozen_string_literal: true # This validator ensures the scope is a scope of a component scope class ScopeBelongsToComponentValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return unless component_for(record) record.errors.add(attribute, :invalid) if component_for(record).out_of_scope?(Decidim::Scope.find_by(id: value)) end private def component_for(record) record.try(:component) || record.try(:current_component) end end
Version data entries
58 entries across 58 versions & 1 rubygems