Class: Fluent::Counter::HashValidator
Constant Summary
Constants inherited
from Validator
Validator::VALID_METHODS, Validator::VALID_NAME, Validator::VALID_SCOPE_NAME
Instance Method Summary
collapse
Methods inherited from Validator
#call, #initialize, request
Instance Method Details
#validate_name!(hash) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# 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) ⇒ Object
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# 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) ⇒ Object
117
118
119
120
121
122
123
124
125
126
|
# 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
|