require_relative "ohm" if defined?(Ohm) class Scrivener module Validations def assert_confirmation(att, error = [att, :not_confirmed]) confirmation = :"#{att}_confirmation" if assert_present(confirmation, error) assert(send(confirmation) == send(att), error) end end def assert_minimum_length(att, val, error = [att, :too_short]) assert(send(att).to_s.length >= val, error) end def assert_maximum_length(att, val, error = [att, :too_long]) assert(send(att).to_s.length <= val, error) end def assert_exact_length(att, val, error = [att, :wrong_length]) assert(send(att).to_s.length == val, error) end end end