Class: Canvas::Validator::SchemaAttribute::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/canvas/validators/schema_attributes/base.rb

Overview

:documented:

Validations to run against an attribute’s schema that are shared across types. This class acts as the base class for type-specific validators.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute) ⇒ Base

Returns a new instance of Base.



14
15
16
17
# File 'lib/canvas/validators/schema_attributes/base.rb', line 14

def initialize(attribute)
  @attribute = attribute
  @errors = []
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



12
13
14
# File 'lib/canvas/validators/schema_attributes/base.rb', line 12

def attribute
  @attribute
end

#errorsObject (readonly)

Returns the value of attribute errors.



12
13
14
# File 'lib/canvas/validators/schema_attributes/base.rb', line 12

def errors
  @errors
end

Instance Method Details

#validateObject



19
20
21
22
23
# File 'lib/canvas/validators/schema_attributes/base.rb', line 19

def validate
  ensure_has_required_keys &&
    ensure_no_unrecognized_keys &&
    ensure_keys_are_correct_types
end