module ActiveModel module Validations class FalsityValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) record.errors.add(attribute, :falsity, :message => options[:message], :value => value) unless value.is_a?(FalseClass) end end module HelperMethods def validates_falsity_of(*attr_names) validates_with FalsityValidator, _merge_attributes(attr_names) end alias validates_falsehood_of validates_falsity_of end end end