Sha256: b31ccdcbd2265d281bc433e7707b713ca0df7f74c3c945c0d38a9b28c2e428f5
Contents?: true
Size: 407 Bytes
Versions: 3
Compression:
Stored size: 407 Bytes
Contents
# frozen_string_literal: true class RespondToValidator < ActiveModel::EachValidator def validate_each(obj, attribute, value) with_option = Array.wrap(options[:with] || options[:in]) return if with_option.all? { value.respond_to?(_1) } expectation = with_option.map(&:inspect).join(" & ") obj.errors.add(attribute, (options[:message] || "does not respond to #{expectation}")) end end
Version data entries
3 entries across 3 versions & 1 rubygems