Sha256: e74c88826e72b4e7b4a71c11f2dca40139346fde91e7f5ff71e05a630825750e
Contents?: true
Size: 825 Bytes
Versions: 16
Compression:
Stored size: 825 Bytes
Contents
# frozen_string_literal: true # A custom validator to make sure features are correctly assigned to a model. # # Adds a presence validation and checks that the manifest is the correct one. class FeatureValidator < ActiveModel::EachValidator # Validates the arguiments passed to the validator. def check_validity! raise ArgumentError, "You must include a `manifest` option with the name of the manifest to validate when validating a feature" if options[:manifest].blank? end # The actual validator method. It is called when ActiveRecord iterates # over all the validators. def validate_each(record, attribute, feature) unless feature record.errors[attribute] << :blank return end record.errors[attribute] << :invalid if feature.manifest_name.to_s != options[:manifest].to_s end end
Version data entries
16 entries across 16 versions & 1 rubygems