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