[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/core](../../README) / [config](../README) / ConfigLoader

# Class: ConfigLoader

Defined in: [config/ConfigLoader.ts:20](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/config/ConfigLoader.ts#L20)

A loaded set of config files, keyed by filename (`config/app.ts` → `app`). Pass `all()` (or the
loader itself) to `Application.create({ config })` / `app.useConfig(...)`.

## Constructors

### Constructor

> **new ConfigLoader**(`_map`, `_validators?`): `ConfigLoader`

Defined in: [config/ConfigLoader.ts:21](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/config/ConfigLoader.ts#L21)

#### Parameters

##### \_map

[`ConfigMap`](../type-aliases/ConfigMap)

##### \_validators?

readonly `object`[] = `[]`

#### Returns

`ConfigLoader`

## Methods

### all()

> **all**(): [`ConfigMap`](../type-aliases/ConfigMap)

Defined in: [config/ConfigLoader.ts:27](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/config/ConfigLoader.ts#L27)

The full namespace → config map.

#### Returns

[`ConfigMap`](../type-aliases/ConfigMap)

***

### get()

> **get**\<`T`\>(`key`, `fallback?`): `T`

Defined in: [config/ConfigLoader.ts:38](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/config/ConfigLoader.ts#L38)

Dot-path read, e.g. `get("database.url")`.

#### Type Parameters

##### T

`T` = `unknown`

#### Parameters

##### key

`string`

Dot-notation path across the loaded namespaces.

##### fallback?

`T`

Value returned when the path is missing.

#### Returns

`T`

The stored value, or `fallback` when unset.

***

### has()

> **has**(`key`): `boolean`

Defined in: [config/ConfigLoader.ts:51](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/config/ConfigLoader.ts#L51)

Whether a value exists at the given dot-path.

#### Parameters

##### key

`string`

#### Returns

`boolean`

***

### validate()

> **validate**(): `this`

Defined in: [config/ConfigLoader.ts:63](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/config/ConfigLoader.ts#L63)

Run each config file's optional `validate(config)` named export against its value, throwing on
the first failure. Returns `this` for chaining. (Config files that read env at module load are
already validated by the act of loading.)

#### Returns

`this`

`this`, so the call chains into `Application.create({ config })`.

#### Throws

Whatever a config file's `validate(config)` export throws on the first failure.
