Sha256: 6b85f6d32979faf74ff30b5d01145e9be77ebcd6c5214a96eb031bb3522271ae

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module Legion
  module Settings
    module Validators
      module Legion
        # Validate Legion spawn.
        # Validates: limit
        #
        # @param legion [Hash] legion definition.
        def validate_legion_spawn(legion)
          spawn = legion[:spawn]
          if is_a_hash?(spawn)
            if is_an_integer?(spawn[:limit])
              (spawn[:limit]).positive? ||
                invalid(legion, 'legion spawn limit must be greater than 0')
            else
              invalid(legion, 'legion spawn limit must be an integer')
            end
          else
            invalid(legion, 'legion spawn must be a hash')
          end
        end

        # Validate a Legion definition.
        # Validates: spawn
        #
        # @param legion [Hash] legion definition.
        def validate_legion(legion)
          if is_a_hash?(legion)
            validate_legion_spawn(legion)
          else
            invalid(legion, 'legion must be a hash')
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
legion-settings-0.1.1 lib/legion/settings/validators/legion.rb
legion-settings-0.1.0 lib/legion/settings/validators/legion.rb