Hyperlinkv0.8.0-beta.28

Config

Config.literalsfunctioneffect/Config.ts:1044
<const L extends ReadonlyArray<SchemaAST.LiteralValue>>(
  literals: L,
  name?: string
): Config<L[number]>

Creates a config that only accepts one of the specified literal values.

When to use

Use to restrict a config to a fixed set of allowed literal values.

Details

Shortcut for Config.schema(Schema.Literals(literals), name).

Example (Restricting to a set of literals)

import { Config } from "effect"

const env = Config.literals(["development", "production"], "ENV")
constructorsliteral
Source effect/Config.ts:10443 lines
export function literals<const L extends ReadonlyArray<SchemaAST.LiteralValue>>(literals: L, name?: string) {
  return schema(Schema.Literals(literals), name)
}