Class: Apipie::Validator::EnumValidator
Overview
arguments value must be one of given in array
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#error, #expected_type, find, inherited, #merge_with, #param_name, #params_ordered, #to_json, #to_s, #valid?
Constructor Details
#initialize(param_description, argument) ⇒ EnumValidator
138
139
140
141
|
# File 'lib/apipie/validator.rb', line 138
def initialize(param_description, argument)
super(param_description)
@array = argument
end
|
Class Method Details
.build(param_description, argument, options, proc) ⇒ Object
147
148
149
|
# File 'lib/apipie/validator.rb', line 147
def self.build(param_description, argument, options, proc)
self.new(param_description, argument) if argument.is_a?(Array)
end
|
Instance Method Details
#description ⇒ Object
151
152
153
|
# File 'lib/apipie/validator.rb', line 151
def description
"Must be one of: #{@array.join(', ')}."
end
|
#validate(value) ⇒ Object
143
144
145
|
# File 'lib/apipie/validator.rb', line 143
def validate(value)
@array.include?(value)
end
|