Class: Apipie::Validator::ArrayValidator
- Inherits:
-
BaseValidator
- Object
- BaseValidator
- Apipie::Validator::ArrayValidator
- Defined in:
- lib/apipie/validator.rb
Overview
arguments value must be one of given in array
Instance Attribute Summary
Attributes inherited from BaseValidator
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(param_description, argument) ⇒ ArrayValidator
constructor
A new instance of ArrayValidator.
- #validate(value) ⇒ Object
Methods inherited from BaseValidator
#error, #expected_type, find, inherited, #merge_with, #param_name, #to_json, #to_s, #valid?
Constructor Details
#initialize(param_description, argument) ⇒ ArrayValidator
Returns a new instance of ArrayValidator.
135 136 137 138 |
# File 'lib/apipie/validator.rb', line 135 def initialize(param_description, argument) super(param_description) @array = argument end |
Class Method Details
.build(param_description, argument, options, proc) ⇒ Object
144 145 146 |
# File 'lib/apipie/validator.rb', line 144 def self.build(param_description, argument, , proc) self.new(param_description, argument) if argument.is_a?(Array) end |
Instance Method Details
#description ⇒ Object
148 149 150 |
# File 'lib/apipie/validator.rb', line 148 def description "Must be one of: #{@array.join(', ')}." end |
#validate(value) ⇒ Object
140 141 142 |
# File 'lib/apipie/validator.rb', line 140 def validate(value) @array.include?(value) end |