function validateArrayNext()

in src/validation/validateStates.ts [174:204]


function validateArrayNext(
  arrayPropName: string,
  oneStateValueNode: ObjectASTNode,
  stateNames: string[],
  document: TextDocument,
): ValidateCatchResult {
  const arrayPropNode = findPropChildByName(oneStateValueNode, arrayPropName)
  const diagnostics: Diagnostic[] = []
  const reachedStates: { [ix: string]: boolean } = {}

  if (arrayPropNode?.valueNode && isArrayNode(arrayPropNode.valueNode)) {
    arrayPropNode.valueNode.items.forEach((item) => {
      if (isObjectNode(item)) {
        const nextProp = findPropChildByName(item, 'Next')

        if (nextProp) {
          const nextPropValue = nextProp.valueNode?.value
          const diagnostic = stateNameExistsInPropNode(nextProp, stateNames, document, MESSAGES.INVALID_NEXT)

          if (diagnostic) {
            diagnostics.push(diagnostic)
          } else if (typeof nextPropValue === 'string') {
            reachedStates[nextPropValue] = true
          }
        }
      }
    })
  }

  return { diagnostics, reachedStates }
}