This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/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