Sha256: f032b3b1637070d3b55e742032e80917bea9328a1e39a5625505886523ca882a

Contents?: true

Size: 477 Bytes

Versions: 1

Compression:

Stored size: 477 Bytes

Contents

# frozen_string_literal: true

require_relative '../contracts'

module BCDD
  module Contracts
    is_uuid = ->(val) { val.match?(/\A[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}\z/) or '%p must be an UUID' }

    register(is_uuid: contract[::String] & :is_present & is_uuid)
  end

  module Values
    register(
      name: :uuid,
      type: ::String,
      contract: :is_uuid,
      normalize: -> { _1.strip.downcase },
      default: -> { ::SecureRandom.uuid }
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bcdd-process-0.4.0 examples/business_processes/lib/bcdd/values/uuid.rb