Class: OrganizationPresentValidator

Inherits:
ActiveModel::Validations::FileContentTypeValidator show all
Defined in:
app/validators/organization_present_validator.rb

Overview

Validates that the associated record is always within an organization in order to pass the organization specific settings for the file upload checks (e.g. file extension, mime type, etc.).

Instance Method Summary collapse

Methods inherited from ActiveModel::Validations::FileContentTypeValidator

#mark_invalid_original

Instance Method Details

#check_validity!Object



14
# File 'app/validators/organization_present_validator.rb', line 14

def check_validity!; end

#validate_each(record, attribute, _value) ⇒ Object



7
8
9
10
11
12
# File 'app/validators/organization_present_validator.rb', line 7

def validate_each(record, attribute, _value)
  return if record.is_a?(Decidim::Organization)
  return if record.respond_to?(:organization) && record.organization.is_a?(Decidim::Organization)

  record.errors.add attribute, I18n.t("carrierwave.errors.not_inside_organization")
end