Class: Jschematic::Attributes::MinItems
- Inherits:
-
Object
- Object
- Jschematic::Attributes::MinItems
- Includes:
- Element
- Defined in:
- lib/jschematic/attributes/min_items.rb
Instance Attribute Summary
Attributes included from Element
Instance Method Summary collapse
- #accepts?(instance) ⇒ Boolean
-
#initialize(min_items) ⇒ MinItems
constructor
A new instance of MinItems.
Methods included from Element
#required?, #schema_for, #title, #to_s
Constructor Details
#initialize(min_items) ⇒ MinItems
Returns a new instance of MinItems.
8 9 10 |
# File 'lib/jschematic/attributes/min_items.rb', line 8 def initialize(min_items) @min_items = min_items end |
Instance Method Details
#accepts?(instance) ⇒ Boolean
12 13 14 15 |
# File 'lib/jschematic/attributes/min_items.rb', line 12 def accepts?(instance) return true unless Array === instance (instance.length >= @min_items) || fail_validation!("at least #{@min_items}", instance.length) end |