Sha256: 26db8e6dd17783b53bdbe48414aa779f0456419f5658d0b20cd89bc45d79e86e

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scrivener-contrib-0.0.1 lib/scrivener/contrib.rb