TOML adapter
Load configuration from a TOML file.
Loads the configuration from a toml file.
Install
This adapter needs the smol-toml peer dependency, if you don't have it already:
npm install smol-tomlThe TOML adapter is synchronous, so it also works with loadConfigSync.
Usage
import { } from 'zod';
import { } from 'zod-config';
import { } from 'zod-config/toml-adapter';
import path from 'path';
const = .({
: .().(/^\d+$/),
: .(),
});
const = path.(, 'config.toml');
const = await ({
: ,
: ({ : }),
});
// using filter regex to match only the keys we need
const = await ({
: ,
: ({
: ,
: /^MY_APP_/,
}),
});Options
| Option | Type | Description |
|---|---|---|
path | string | Path to the TOML file. Required. |
Also accepts the shared adapter options: regex, silent, keyMatching and transform.