Skip to content

yamlStreamLoader

yamlStreamLoader<T>(schema, config): LoaderReturn<T>

Defined in: packages/core/src/loaders.ts:181

Loads and parses YAML files containing multiple documents, validating each document against a schema. Supports both .yaml and .yml file extensions. Each file can contain multiple YAML documents separated by ---.

T extends AnyStruct

The schema type extending AnyStruct

T

Effect Schema used to validate and decode each YAML document

Configuration object

string

Path to the directory containing YAML files

LoaderReturn<T>

A Stream of validated objects matching the schema type, one per YAML document

When no YAML files are found, parsing fails, or validation fails

const ArticleSchema = Schema.Struct({
title: Schema.String,
content: Schema.String,
});
// Handles files with multiple YAML documents:
// ---
// title: "First"
// ---
// title: "Second"
const articles = yamlStreamLoader(ArticleSchema, { folder: './articles' });