Sha256: cb2d721bc3f6372e2b8efb02210f034c46b374569fabe9457b887f166e766274

Contents?: true

Size: 634 Bytes

Versions: 2

Compression:

Stored size: 634 Bytes

Contents

require_relative 'base'

# Namespace for the Opushon library.
module Opushon
  module Type
    # The type string.
    class String < Base
      def initialize( minlen:   nil,
                      maxlen:   nil,
                      pattern:  nil )

        if !minlen.nil? && !maxlen.nil?
          fail MinlenIsLongerThanMaxlenError if minlen > maxlen
        end

        @minlen   = minlen
        @maxlen   = maxlen
        @pattern  = pattern

        freeze
      end

      def constraints
        {
          minlen:   @minlen,
          maxlen:   @maxlen,
          pattern:  @pattern
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opushon-0.1.1 lib/opushon/type/string.rb
opushon-0.1.0 lib/opushon/type/string.rb