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

7 lines
245 B
Ruby

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