orbit-4-2/config/initializers/custom_validators.rb

7 lines
245 B
Ruby
Raw Permalink Normal View History

class AtLeastOneValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || I18n.t("errors.at_least_one")) if (value.blank? || value.values.join.eql?(''))
end
end