Function
makeStrictType
(
typeChecker: (value: unknown) => boolean,
typeName: string,
)
Source from the content-addressed store, hash-verified
| 756 | |
| 757 | // Helper to create a strict type validator |
| 758 | function makeStrictType<T>( |
| 759 | typeChecker: (value: unknown) => boolean, |
| 760 | typeName: string, |
| 761 | ): StandardSchemaV1<T> { |
| 762 | return { |
| 763 | "~standard": { |
| 764 | version: 1, |
| 765 | vendor: "codemix-test", |
| 766 | validate: (value) => { |
| 767 | if (typeChecker(value)) { |
| 768 | return { value: value as T }; |
| 769 | } |
| 770 | return { |
| 771 | issues: [{ message: `Expected ${typeName}, received ${typeof value}` }], |
| 772 | }; |
| 773 | }, |
| 774 | }, |
| 775 | }; |
| 776 | } |
| 777 | |
| 778 | // Schema with strict type validation |
| 779 | const strictSchema = { |
Tested by
no test coverage detected