Class: Canvas::Validator::CustomTypeLayoutSchema
- Inherits:
-
Object
- Object
- Canvas::Validator::CustomTypeLayoutSchema
- Defined in:
- lib/canvas/validators/custom_type_layout_schema.rb
Overview
:documented: This class is used to validate a layout definition for a custom type. Custom type layouts use a flat array of elements (unlike block layouts which use tabs).
Example of a valid custom type layout definition: {
"attributes" => [
{ "name" => "question", "type" => "string" },
{ "name" => "answer", "type" => "text" },
{ "name" => "show_icon", "type" => "boolean" }
],
"layout" => [
"question",
{
"type" => "accordion",
"label" => "Advanced",
"elements" => [
"answer",
{ "type" => "attribute", "name" => "show_icon" }
]
}
]
}
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(schema:) ⇒ CustomTypeLayoutSchema
constructor
A new instance of CustomTypeLayoutSchema.
- #validate ⇒ Object
Constructor Details
#initialize(schema:) ⇒ CustomTypeLayoutSchema
Returns a new instance of CustomTypeLayoutSchema.
34 35 36 37 |
# File 'lib/canvas/validators/custom_type_layout_schema.rb', line 34 def initialize(schema:) @schema = schema @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
32 33 34 |
# File 'lib/canvas/validators/custom_type_layout_schema.rb', line 32 def errors @errors end |
Instance Method Details
#validate ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/canvas/validators/custom_type_layout_schema.rb', line 39 def validate @errors = [] if ensure_valid_format ensure_no_unrecognized_keys ensure_no_duplicate_keys ensure_accordion_toggles_are_valid end @errors.empty? end |