Class: Sekisyo::Validators::ArrayValidator
- Inherits:
-
Object
- Object
- Sekisyo::Validators::ArrayValidator
- Defined in:
- lib/sekisyo/validators/array_validator.rb
Overview
Sekisyo Validators ArrayValidator is a validator that accepts only array value.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key, options = {}) ⇒ ArrayValidator
constructor
A new instance of ArrayValidator.
- #valid?(value) ⇒ Boolean
Constructor Details
#initialize(key, options = {}) ⇒ ArrayValidator
Returns a new instance of ArrayValidator.
9 10 11 12 13 14 15 16 17 |
# File 'lib/sekisyo/validators/array_validator.rb', line 9 def initialize(key, = {}) @key = key @options = @items_options = @options.fetch('items', {}) items_validator_class = Sekisyo::Validator::VALIDATORS[@items_options.delete('type')] items_validator_class ||= Sekisyo::Validators::AnyValidator @items_validator = items_validator_class.new(nil, @items_options) end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
19 20 21 |
# File 'lib/sekisyo/validators/array_validator.rb', line 19 def key @key end |
Instance Method Details
#valid?(value) ⇒ Boolean
21 22 23 24 25 26 27 28 |
# File 'lib/sekisyo/validators/array_validator.rb', line 21 def valid?(value) type_validate(value) && presence_validate(value) && bytesize_validate(value) && min_size_validate(value) && max_size_validate(value) && items_validate(value) end |