MCPcopy Create free account
hub / github.com/codemix/graph / makeIntegerType

Function makeIntegerType

packages/graph/src/test/standardSchema.test.ts:57–73  ·  view source on GitHub ↗

* Creates a schema that parses string numbers to integers.

()

Source from the content-addressed store, hash-verified

55 * Creates a schema that parses string numbers to integers.
56 */
57function makeIntegerType(): StandardSchemaV1<string | number, number> {
58 return {
59 "~standard": {
60 version: 1,
61 vendor: "test",
62 validate: (value) => {
63 const num = typeof value === "number" ? value : parseInt(String(value), 10);
64 if (isNaN(num)) {
65 return {
66 issues: [{ message: "Expected integer" }],
67 };
68 }
69 return { value: num };
70 },
71 },
72 };
73}
74
75/**
76 * Creates a schema that always fails validation.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected