Class: Canvas::Validator::LayoutSchema
- Inherits:
-
Object
- Object
- Canvas::Validator::LayoutSchema
- Defined in:
- lib/canvas/validators/layout_schema.rb
Overview
:documented: This class is used to validate a layout definition, part of block schema. Example of a valid layout definition: { "attributes" => { "title" => { "type" => "string" } ... }, "layout" => [ { "label" => "Design", "type" => "tab", "elements" => [ "heading", { "type" => "accordion", "label" => "Logo", "elements" => [ "description", { "type" => "attribute", "name" => "logo_alt" }, "title" ] }, { "type" => "accordion_toggle", "toggle_attribute" => "cta_enabled", "elements" => [ "cta_text", "cta_target" ] } ] } ] }
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(schema:) ⇒ LayoutSchema
constructor
A new instance of LayoutSchema.
- #validate ⇒ Object
Constructor Details
#initialize(schema:) ⇒ LayoutSchema
Returns a new instance of LayoutSchema.
48 49 50 51 |
# File 'lib/canvas/validators/layout_schema.rb', line 48 def initialize(schema:) @schema = schema @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
46 47 48 |
# File 'lib/canvas/validators/layout_schema.rb', line 46 def errors @errors end |
Instance Method Details
#validate ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/canvas/validators/layout_schema.rb', line 53 def validate @errors = [] if ensure_valid_format ensure_no_unrecognized_keys ensure_no_duplicate_keys ensure_accordion_toggles_are_valid ensure_unique_tabs end @errors.empty? end |