Repository navigation
Replies: 1 comment
|
Yes. In ArkType 2.2.8, attach a description to the field's type with import { scope, type } from "arktype";
const $ = scope({
param: {
answer: type.number.describe("a number (try 42)"),
},
}).export();
const result = $.param({ answer: "oops" });
if (result instanceof type.errors) {
console.log(result.summary);
// answer must be a number (try 42) (was a string)
}This keeps the description next to the field definition and uses it in validation diagnostics. It still validates the field as a number; I compiled this example with TypeScript 7.0.2 and ran it with ArkType 2.2.8. The error configuration documentation describes |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Something like...
...would be nice to have (with any syntax) — I'd like to make the diagnostics more readable for my users, yet I'd like to keep the documentation in the same spot as the schema itself in the code.
All reactions