Sha256: 04f4faa992f1b2b52c8f9200f7d4b3ee7b97fdc8b9f39ac8df6da4203137aacf
Contents?: true
Size: 1.31 KB
Versions: 8
Compression:
Stored size: 1.31 KB
Contents
module Formalist class Form class ValidityCheck def call(form_ast) form_ast.map { |node| visit(node) }.all? end alias_method :[], :call private def visit(node) name, nodes = node send(:"visit_#{name}", nodes) end def visit_attr(node) _name, _type, errors, _attributes, children = node errors.empty? && children.map { |child| visit(child) }.all? end def visit_compound_field(node) _type, _attributes, children = node children.map { |child| visit(child) }.all? end def visit_field(node) _name, _type, _input, errors, _attributes = node errors.empty? end def visit_group(node) _type, _attributes, children = node children.map { |child| visit(child) }.all? end def visit_many(node) _name, _type, errors, _attributes, _child_template, children = node # The `children`` parameter for `many` elements is for some reason # doubly nested right now, so we need to flatten it. errors.empty? && children.flatten(1).map { |child| visit(child) }.all? end def visit_section(node) _name, _type, _attributes, children = node children.map { |child| visit(child) }.all? end end end end
Version data entries
8 entries across 8 versions & 1 rubygems