export function isInputConfigValid()

in util/config/configurator/configurator.ts [337:370]


export function isInputConfigValid(body: Record<string, any>): boolean {
  // 1. If the body is empty, return false
  if (Object.keys(body).length === 0) {
    return false;
  }

  // 2. Check that each key in the body has the keys as the Prompt type
  for (const key in body) {
    const value = body[key];
    if (typeof value !== "object") {
      return false;
    }

    if (!value.type) {
      return false;
    }

    if (
      !["string", "int", "float", "bool", "password"].includes(value.type) &&
      !Array.isArray(value.type)
    ) {
      return false;
    }
  }

  // 3. Check that all the keys are uppercase and can only have underscores not at the beginning or end
  for (const key in body) {
    if (!/^[A-Z][A-Z_]|[0-9]*[A-Z]|[0-9]$/.test(key)) {
      return false;
    }
  }

  return true;
}