(...literals: Literals)
| 302 | |
| 303 | /** @internal */ |
| 304 | export const literal = <Literals extends ReadonlyArray<Config.LiteralValue>>(...literals: Literals) => |
| 305 | ( |
| 306 | name?: string |
| 307 | ): Config.Config<Literals[number]> => { |
| 308 | const valuesString = literals.map(String).join(", ") |
| 309 | const config = primitive(`one of (${valuesString})`, (text) => { |
| 310 | const found = literals.find((value) => String(value) === text) |
| 311 | if (found === undefined) { |
| 312 | return Either.left( |
| 313 | configError.InvalidData( |
| 314 | [], |
| 315 | `Expected one of (${valuesString}) but received ${formatUnknown(text)}` |
| 316 | ) |
| 317 | ) |
| 318 | } |
| 319 | return Either.right(found) |
| 320 | }) |
| 321 | return name === undefined ? config : nested(config, name) |
| 322 | } |
| 323 | |
| 324 | /** @internal */ |
| 325 | export const logLevel = (name?: string): Config.Config<LogLevel.LogLevel> => { |
nothing calls this directly
no test coverage detected