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 ---
.
Type Parameters
Section titled “Type Parameters”T
extends AnyStruct
The schema type extending AnyStruct
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Effect Schema used to validate and decode each YAML document
config
Section titled “config”Configuration object
folder
Section titled “folder”string
Path to the directory containing YAML files
Returns
Section titled “Returns”LoaderReturn
<T
>
A Stream of validated objects matching the schema type, one per YAML document
Throws
Section titled “Throws”When no YAML files are found, parsing fails, or validation fails
Example
Section titled “Example”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' });