fix: validate payload against schema in put command #57
Reference in New Issue
Block a user
Delete Branch "fix/50-schema-validation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
This PR fixes issue #50 by adding schema validation to the
json-cas putcommand. The CLI now validates payloads against their schemas before storing them in the CAS.Why
Previously,
json-cas put <type-hash> <file.json>would accept any JSON payload without validating it against the specified schema. This undermined the core type-safety guarantee of json-cas.Changes
Modified Files
packages/cli-json-cas/src/index.ts(+17 lines)validate()functionCasNodewith timestamp for validationpackages/cli-json-cas/src/cli.test.ts(+587 lines)Verification
bun run build- Clean TypeScript compilationbun run check- No Biome lint errorsExample Usage
Valid payload (accepted):
Invalid payload (rejected):
Ref
Fixes #50
LGTM ✅ 🟡 cmdPut 里用了 console.error + process.exit(1),应该用 die() 保持一致。💡 注意和 #58 会冲突(都改 cmdPut),协调合并顺序。