Sha256: b19d553e6c6c4873fbeab8eab21036a689927e40d7ac21a39d797bf83f582266

Contents?: true

Size: 1.55 KB

Versions: 5

Compression:

Stored size: 1.55 KB

Contents

##
# Validation mix-in module
require "steps/sp_steps_kv_pb"

module Validation
  def validate_set_pipelines(cmd)
    if cmd.nil?
      raise "cmd is required"
    end

    if cmd.audience.nil?
      raise "audience is required"
    end

    if cmd.set_pipelines.nil?
      raise "set_pipelines command is required"
    end

    cmd.set_pipelines.each do |pipeline|
      if pipeline.id == ""
        raise "pipeline id is required"
      end
    end
  end

  def validate_kv_command(cmd)
    if cmd.nil?
      raise "cmd is required"
    end

    if cmd.kv.nil?
      raise "kv command is required"
    end
  end

  def validate_kv_instruction(inst)
    if inst.nil?
      raise "instruction is required"
    end

    if inst.id == ""
      raise "instruction id is required"
    end

    if inst.action.nil?
      raise "instruction action is required"
    end

    if inst.action == :KV_ACTION_UNSET
      raise "instruction action is required"
    end

    if inst.object.nil? and inst.action != :KV_ACTION_DELETE_ALL
      raise "instruction object is required"
    end

    validate_kv_object(inst.object)
  end

  def validate_kv_object(obj)
    if obj.nil?
      raise "object is required"
    end

    if obj.key == ""
      raise "kv object key is required"
    end

    if obj.value == ""
      raise "kv object value is required"
    end

  end

  def validate_tail_request(cmd)
    if cmd.nil?
      raise "cmd is required"
    end

    if cmd.audience.nil?
      raise "audience is required"
    end

    if cmd.tail.nil?
      raise "tail is required"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
streamdal-0.0.5 lib/validation.rb
streamdal-0.0.4 lib/validation.rb
streamdal-0.0.3 lib/validation.rb
streamdal-0.0.2 lib/validation.rb
streamdal-0.0.1 lib/validation.rb