fluke/devops-service/db/validators/not_nil.rb

8 lines
224 B
Ruby
Raw Normal View History

2018-04-04 22:44:39 +03:00
class NotNilValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if value.nil?
record.errors.add attribute, (options[:message] || "#{attribute} should not be nil")
end
end
end