Sha256: db3a0e814ade49af1379746a63bf7275b1bd5b22bfb7e9a97fb6899ed90f9a4c

Contents?: true

Size: 570 Bytes

Versions: 2

Compression:

Stored size: 570 Bytes

Contents

require_relative 'base'

# Namespace for the Taipu library.
module Taipu
  # 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
taipu-0.0.2 lib/taipu/string.rb
taipu-0.0.1 lib/taipu/string.rb