src/shared/utils/validator/index.js
function validatePage(page, path) {
  let errors = [];

  // Check for required properties
  errors = [...errors, ...assertProperties(page, path, requiredProperties[page.type])];

  if (page.children) {
    // Check that children is an array
    if (!Array.isArray(page.children)) {
      errors = [...errors, { path, error: 'Children must be an array' }];

      return errors;
    }

    page.children.forEach((node, index) => {
      errors = [...errors, ...validateNode(node, [...path, 'children', index], [page])];
    });
  }

  return errors;
}
function validatePage(page, path) {
  let errors = [];

  // Check for required properties
  errors = [...errors, ...assertProperties(page, path, requiredProperties[page.type])];

  if (page.children) {
    // Check that children is an array
    if (!Array.isArray(page.children)) {
      errors = [...errors, { path, error: 'Children must be an array' }];

      return errors;
    }

    page.children.forEach((node, index) => {
      errors = [...errors, ...validateNode(node, [...path, 'children', index], [page])];
    });
  }

  return errors;
}
function validatePage ( page , path ) { let errors = [ ] ; // Check for required properties errors = [ ... errors , ... assertProperties ( page , path , requiredProperties [ page . type ] ) ] ; if ( page . children ) { // Check that children is an array if ( ! Array . isArray ( page . children ) ) { errors = [ ... errors , { path , error : 'Children must be an array' } ] ; return errors ; } page . children . forEach ( ( node , index ) => { errors = [ ... errors , ... validateNode ( node , [ ... path , 'children' , index ] , [ page ] ) ] ; } ) ; } return errors ; }
Validate a page, checking that the required properties are in place
Validate a page checking that the required properties are in place