Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions skills/rig/rig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2652,6 +2652,13 @@ function describeSchemaType(schema: Schema): string {
return `array of ${itemType}`;
}
if ("type" in schema) {
if ((schema as { type: string }).type === "string") {
const { minLength, format } = schema as StringSchema;
if (format === "uri") return "URL string";
if (format === "date") return "date string (YYYY-MM-DD)";
if (format === "path") return "path string";
if (minLength !== undefined && minLength > 0) return "non-empty string";
}
return (schema as { type: string }).type;
}
if ("enum" in schema) {
Expand Down
44 changes: 44 additions & 0 deletions src/rig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1962,4 +1962,48 @@ describe("missing required field error message", () => {
expect(result.error.message).toContain("any");
}
});

it("reports a missing required s.nonEmptyString field as 'non-empty string'", () => {
const schema = s.object({ slug: s.nonEmptyString, name: s.string });
const result = analyzeResponse(JSON.stringify({ name: "x" }), schema, "test", 1);
expect(result.ok).toBe(false);
if (!result.ok) {
expect(result.error.message).toContain("missing required field");
expect(result.error.message).toContain("$.slug");
expect(result.error.message).toContain("non-empty string");
}
});

it("reports a missing required s.url field as 'URL string'", () => {
const schema = s.object({ endpoint: s.url, name: s.string });
const result = analyzeResponse(JSON.stringify({ name: "x" }), schema, "test", 1);
expect(result.ok).toBe(false);
if (!result.ok) {
expect(result.error.message).toContain("missing required field");
expect(result.error.message).toContain("$.endpoint");
expect(result.error.message).toContain("URL string");
}
});

it("reports a missing required s.date field as 'date string (YYYY-MM-DD)'", () => {
const schema = s.object({ createdAt: s.date, name: s.string });
const result = analyzeResponse(JSON.stringify({ name: "x" }), schema, "test", 1);
expect(result.ok).toBe(false);
if (!result.ok) {
expect(result.error.message).toContain("missing required field");
expect(result.error.message).toContain("$.createdAt");
expect(result.error.message).toContain("date string (YYYY-MM-DD)");
}
});

it("reports a missing required s.path field as 'path string'", () => {
const schema = s.object({ filePath: s.path, name: s.string });
const result = analyzeResponse(JSON.stringify({ name: "x" }), schema, "test", 1);
expect(result.ok).toBe(false);
if (!result.ok) {
expect(result.error.message).toContain("missing required field");
expect(result.error.message).toContain("$.filePath");
expect(result.error.message).toContain("path string");
}
});
});
Loading