class Formalist::Form::ValidityCheck
Public Instance Methods
call(form_ast)
click to toggle source
# File lib/formalist/form/validity_check.rb, line 4 def call(form_ast) form_ast.map { |node| visit(node) }.all? end
Also aliased as: []
Private Instance Methods
visit(node)
click to toggle source
# File lib/formalist/form/validity_check.rb, line 11 def visit(node) name, nodes = node send(:"visit_#{name}", nodes) end
visit_attr(node)
click to toggle source
# File lib/formalist/form/validity_check.rb, line 17 def visit_attr(node) _name, _type, errors, _attributes, children = node errors.empty? && children.map { |child| visit(child) }.all? end
visit_compound_field(node)
click to toggle source
# File lib/formalist/form/validity_check.rb, line 23 def visit_compound_field(node) _type, _attributes, children = node children.map { |child| visit(child) }.all? end
visit_field(node)
click to toggle source
# File lib/formalist/form/validity_check.rb, line 29 def visit_field(node) _name, _type, _input, errors, _attributes = node errors.empty? end
visit_group(node)
click to toggle source
# File lib/formalist/form/validity_check.rb, line 35 def visit_group(node) _type, _attributes, children = node children.map { |child| visit(child) }.all? end
visit_many(node)
click to toggle source
# File lib/formalist/form/validity_check.rb, line 41 def visit_many(node) _name, _type, errors, _attributes, _child_template, children = node # The `children parameter for `many` elements is nested since there are # many groups of elements, we need to flatten to traverse them all errors.empty? && children.flatten(1).map { |child| visit(child) }.all? end
visit_many_forms(node)
click to toggle source
TODO work out what to do with this. I think it’s only relevant to many_forms nested in rich text ast
# File lib/formalist/form/validity_check.rb, line 52 def visit_many_forms(node) _name, _type, errors, _attributes, children = node errors.empty? && children.map { |child| visit(child[:form]) }.all? end
visit_section(node)
click to toggle source
# File lib/formalist/form/validity_check.rb, line 58 def visit_section(node) _name, _type, _attributes, children = node children.map { |child| visit(child) }.all? end