import { readFile } from 'fs/promises'; import { parse as parseYAML } from 'yaml'; import { AnySchema } from 'yup'; export async function loadYamlWithSchema( filePath: string, schema: TSchema, ): Promise { const fileContent = await readFile(filePath, 'utf8'); const yamlDoc: unknown = parseYAML(fileContent); const result = await schema.validate(yamlDoc); return result; }