Summary
isSchemaKind in packages/validators/src/schemas.ts uses the in operator, which walks the prototype chain. Inherited keys like toString, constructor, valueOf, hasOwnProperty are therefore accepted as valid schema kinds.
Reproduction
import { assertSchemaKind, validate } from "@logicsrc/validators";
assertSchemaKind("toString"); // returns "toString" — should throw Unknown schema kind
validate("toString", {}); // crashes: "schema must be object or boolean"
Via the CLI the user gets a confusing crash instead of the intended usage error:
logicsrc-validate toString fixture.json
# Error: schema must be object or boolean <- misleading
# (expected: Unknown schema kind "toString". Expected one of: agent, …)
Cause
export function isSchemaKind(value: string): value is SchemaKind {
return value in schemas; // "toString" in {} === true (prototype chain)
}
Suggested fix
Object.hasOwn(schemas, value) — own-property check only. PR with fix + unit tests incoming.
Summary
isSchemaKindinpackages/validators/src/schemas.tsuses theinoperator, which walks the prototype chain. Inherited keys liketoString,constructor,valueOf,hasOwnPropertyare therefore accepted as valid schema kinds.Reproduction
Via the CLI the user gets a confusing crash instead of the intended usage error:
Cause
Suggested fix
Object.hasOwn(schemas, value)— own-property check only. PR with fix + unit tests incoming.