Skip to content

yamlFilesLoader

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

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

Loads and parses YAML files from a directory, validating each file against a schema. Supports both .yaml and .yml file extensions. Each file is parsed as a single YAML document.

T extends AnyStruct

The schema type extending AnyStruct

T

Effect Schema used to validate and decode the YAML content

Configuration object

string

Path to the directory containing YAML files

LoaderReturn<T>

A Stream of validated objects matching the schema type

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

const ConfigSchema = Schema.Struct({
name: Schema.String,
settings: Schema.Record(Schema.String, Schema.Unknown),
});
const configs = yamlFilesLoader(ConfigSchema, { folder: './configs' });