Module: Bridgetown::ComponentValidation
- Defined in:
- lib/bridgetown-view-component/bridgetown/component_validation.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
5 6 7 |
# File 'lib/bridgetown-view-component/bridgetown/component_validation.rb', line 5 def self.included(klass) klass.attr_reader :frontmatter end |
Instance Method Details
#frontmatter=(yaml_data) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bridgetown-view-component/bridgetown/component_validation.rb', line 9 def frontmatter=(yaml_data) @frontmatter = yaml_data.with_dot_access frontmatter.validate&.each do |variable, type| unless send(variable).is_a?(Kernel.const_get(type)) raise "Validation error while rendering #{self.class}: " \ "`#{variable}' is not of type `#{type}'" end end end |