Repository navigation
Replies: 2 comments
|
@shlroland You need to toString() the error to understand it |
|
To expand on the For the error in your screenshot:
Here is a small reproduction, checked with arktype 2.2.9 on Node 24.22.1: import { type } from "arktype"
const schema = type({ chat: { defaultValue: "object" } })
const result = schema({
chat: { defaultValue: '{"employeeName":"test"}' }
})
if (result instanceof type.errors) {
const error = result[0]
console.log([...error.path]) // ["chat", "defaultValue"]
console.log(error.expected) // an object
console.log(error.actual) // a string
console.log(error.problem) // must be an object (was a string)
console.log(error.message) // chat.defaultValue must be an object (was a string)
console.log(result.summary) // same text here: there is only one error
}For ordinary validation UI/logging, If that screenshot really is a JSON-string-versus-object mismatch, parsing the JSON before this object validator changes the value being validated; it is not something the The current ArkError implementation shows the field visibility and how the displayed strings are derived. The original screenshot predates this version, so I would use the public properties rather than depending on its exact debugger layout. |
Uh oh!
There was an error while loading. Please reload this page.
I'm not very clear about the meaning of these attributes of ArkError (in terms of semantics or when looking at type files), but the property methods on its prototype are indeed quite straightforward. Or is it that these attributes do not need to be understood in daily development?
All reactions