Const// Matches any Map regardless of key/value types
MapSchema.parse(new Map([['key', 'value']])); // ✓ passes
MapSchema.parse(
new Map([
[1, 'one'],
[2, 'two'],
]),
); // ✓ passes
MapSchema.parse(new Map()); // ✓ passes (empty Map)
MapSchema.parse({}); // ✗ fails (plain object)
MapSchema.parse(new WeakMap()); // ✗ fails (use AnyMapSchema)
Schema that matches any
Mapinstance, including those with any key-value types.This schema provides runtime type checking for Map instances without requiring compile-time knowledge of key or value schemas. It uses
instanceofchecking to verify Map structure while being agnostic about the contained data types.Usage in Assertions:
expect(myMap, 'to have size', 5)expect(myMap, 'to have key', 'someKey')expect(myMap, 'to have value', expectedValue)expect(myMap, 'to have entry', [key, value])expect(mapA, 'to equal', mapB)Advantages Over
z.map():