Skip to Content
Zod Config

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-toml

The 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

OptionTypeDescription
pathstringPath to the TOML file. Required.

Also accepts the shared adapter options: regex, silent, keyMatching and transform.

On this page