Sha256: dff94624f7edd7f5d18ba523f1215ba4dbf3d237b9c14a2d91177a7a5f7b671e

Contents?: true

Size: 633 Bytes

Versions: 4

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

module WaterDrop
  module Schemas
    # Regexp to check that topic has a valid format
    TOPIC_REGEXP = /\A(\w|\-|\.)+\z/

    # Schema with validation rules for validating that all the message options that
    # we provide to producer ale valid and usable
    # @note Does not validate message itself as it is not our concern
    MessageOptions = Dry::Validation.Schema do
      required(:topic).filled(:str?, format?: TOPIC_REGEXP)
      optional(:key).maybe(:str?, :filled?)
      optional(:partition).filled(:int?, gteq?: 0)
      optional(:partition_key).maybe(:str?, :filled?)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
waterdrop-1.0.1 lib/water_drop/schemas/message_options.rb
waterdrop-1.0.0 lib/water_drop/schemas/message_options.rb
waterdrop-1.0.0.alpha2 lib/water_drop/schemas/message_options.rb
waterdrop-1.0.0.alpha1 lib/water_drop/schemas/message_options.rb