Sha256: ca325ade5ec53fff3239605ec47db30b5efffbf537744a0b1563a49e16bb1faf

Contents?: true

Size: 470 Bytes

Versions: 6

Compression:

Stored size: 470 Bytes

Contents

# frozen_string_literal: true

require "key_vortex/constraint/base"

class KeyVortex
  class Constraint
    class Length < KeyVortex::Constraint::Base
      attr_reader :limit

      def initialize(limit)
        super()
        @limit = limit
      end

      def attribute
        :length
      end

      def within?(constraint)
        super && limit <= constraint.limit
      end

      def accepts?(value)
        value.length <= limit
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
key-vortex-0.2.5 lib/key_vortex/constraint/length.rb
key-vortex-0.2.4 lib/key_vortex/constraint/length.rb
key-vortex-0.2.3 lib/key_vortex/constraint/length.rb
key-vortex-0.2.2 lib/key_vortex/constraint/length.rb
key-vortex-0.2.1 lib/key_vortex/constraint/length.rb
key-vortex-0.2.0 lib/key_vortex/constraint/length.rb