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
