MCPcopy Create free account
hub / github.com/Effect-TS/effect / boolean

Function boolean

packages/effect/src/internal/config.ts:163–191  ·  view source on GitHub ↗
(name?: string)

Source from the content-addressed store, hash-verified

161
162/** @internal */
163export const boolean = (name?: string): Config.Config<boolean> => {
164 const config = primitive(
165 "a boolean property",
166 (text) => {
167 switch (text) {
168 case "true":
169 case "yes":
170 case "on":
171 case "1": {
172 return Either.right(true)
173 }
174 case "false":
175 case "no":
176 case "off":
177 case "0": {
178 return Either.right(false)
179 }
180 default: {
181 const error = configError.InvalidData(
182 [],
183 `Expected a boolean value but received ${formatUnknown(text)}`
184 )
185 return Either.left(error)
186 }
187 }
188 }
189 )
190 return name === undefined ? config : nested(config, name)
191}
192
193/** @internal */
194export const url = (name?: string): Config.Config<URL> => {

Callers 2

core-effect.tsFile · 0.70
stm.tsFile · 0.50

Calls 2

primitiveFunction · 0.85
formatUnknownFunction · 0.85

Tested by

no test coverage detected