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

Function makeSchemaPrimitive

packages/effect/src/unstable/cli/Primitive.ts:119–126  ·  view source on GitHub ↗
(
  tag: string,
  schema: Schema.ConstraintDecoder<T, Environment>
)

Source from the content-addressed store, hash-verified

117 })
118
119const makeSchemaPrimitive = <T>(
120 tag: string,
121 schema: Schema.ConstraintDecoder<T, Environment>
122): Primitive<T> => {
123 const toCodecStringTree = Schema.toCodecStringTree(schema)
124 const decode = Schema.decodeUnknownEffect(toCodecStringTree)
125 return makePrimitive(tag, (value) => Effect.mapError(decode(value), (error) => error.message))
126}
127
128/**
129 * Creates a primitive that parses boolean values from string input.

Callers 1

Primitive.tsFile · 0.85

Calls 3

makePrimitiveFunction · 0.70
decodeFunction · 0.50
toCodecStringTreeMethod · 0.45

Tested by

no test coverage detected