Class: Restapi::Validator::BooleanValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#expected_type, find, inherited, #initialize, #param_name, #to_json, #to_s, #valid?
Class Method Details
.build(param_description, argument, options, block) ⇒ Object
275
276
277
278
279
|
# File 'lib/restapi/validator.rb', line 275
def self.build(param_description, argument, options, block)
if argument == :bool
self.new(param_description)
end
end
|
Instance Method Details
#description ⇒ Object
285
286
287
|
# File 'lib/restapi/validator.rb', line 285
def description
"Has to be a boolean"
end
|
#error ⇒ Object
281
282
283
|
# File 'lib/restapi/validator.rb', line 281
def error
"Parameter #{param_name} expecting to be a boolean value, got: #{@error_value}"
end
|
#validate(value) ⇒ Object
271
272
273
|
# File 'lib/restapi/validator.rb', line 271
def validate(value)
%w[true false].include?(value.to_s)
end
|