class ActiveModel::Validations::NotNullValidator

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/active_model/validations/not_null.rb, line 4
def validate_each(record, attribute, value)
  if value.nil?
    errors_options = options.except(:must_be_set)
    default_message = options[:must_be_set]
    errors_options[:message] ||= default_message if default_message
    record.errors.add(attribute, :must_be_set, **errors_options)
  end
end