MCPcopy
hub / github.com/Effect-TS/effect / declarePrimitive

Function declarePrimitive

packages/effect/src/Schema.ts:1010–1018  ·  view source on GitHub ↗
(
  is: (input: unknown) => input is A,
  annotations?: Annotations.Schema<A>
)

Source from the content-addressed store, hash-verified

1008 )
1009
1010const declarePrimitive = <A>(
1011 is: (input: unknown) => input is A,
1012 annotations?: Annotations.Schema<A>
1013): SchemaClass<A> => {
1014 const decodeUnknown = () => (input: unknown, _: ParseOptions, ast: AST.Declaration) =>
1015 is(input) ? ParseResult.succeed(input) : ParseResult.fail(new ParseResult.Type(ast, input))
1016 const encodeUnknown = decodeUnknown
1017 return makeDeclareClass([], new AST.Declaration([], decodeUnknown, encodeUnknown, toASTAnnotations(annotations)))
1018}
1019
1020/**
1021 * @category api interface

Callers 1

Schema.tsFile · 0.85

Calls 2

makeDeclareClassFunction · 0.85
toASTAnnotationsFunction · 0.85

Tested by

no test coverage detected