Hyperlinkv0.8.0-beta.28

Config

Config.datefunctioneffect/Config.ts:1362
(name?: string): Config<Date>

Creates a config for a Date value parsed from a string.

When to use

Use to read date settings that must parse to valid Date values.

Details

Shortcut for Config.schema(Schema.DateValid, name).

Gotchas

Fails with a SchemaError if the string produces an invalid Date.

Example (Reading a date)

import { Config, ConfigProvider, Effect } from "effect"

const createdAt = Config.date("CREATED_AT")

const provider = ConfigProvider.fromUnknown({ CREATED_AT: "2024-01-15" })
// Effect.runSync(createdAt.parse(provider))
// Date("2024-01-15T00:00:00.000Z")
constructors
Source effect/Config.ts:13623 lines
export function date(name?: string) {
  return schema(Schema.DateValid, name)
}