class Fluent::Counter::HashValidator

Public Instance Methods

validate_name!(hash) click to toggle source
# File lib/fluent/counter/validator.rb, line 102
def validate_name!(hash)
  name = hash['name']
  unless name
    raise Fluent::Counter::InvalidParams.new('`name` is required')
  end

  unless name.is_a?(String)
    raise Fluent::Counter::InvalidParams.new('The type of `name` should be String')
  end

  unless VALID_NAME.match?(name)
    raise Fluent::Counter::InvalidParams.new("`name` is the invalid format")
  end
end
validate_reset_interval!(hash) click to toggle source
# File lib/fluent/counter/validator.rb, line 128
def validate_reset_interval!(hash)
  interval = hash['reset_interval']

  unless interval
    raise Fluent::Counter::InvalidParams.new('`reset_interval` is required')
  end

  unless interval.is_a?(Numeric)
    raise Fluent::Counter::InvalidParams.new('The type of `reset_interval` should be Numeric')
  end

  if interval < 0
    raise Fluent::Counter::InvalidParams.new('`reset_interval` should be a positive number')
  end
end
validate_value!(hash) click to toggle source
# File lib/fluent/counter/validator.rb, line 117
def validate_value!(hash)
  value = hash['value']
  unless value
    raise Fluent::Counter::InvalidParams.new('`value` is required')
  end

  unless value.is_a?(Numeric)
    raise Fluent::Counter::InvalidParams.new("The type of `value` type should be Numeric")
  end
end