How do I name a morph?
import { type } from "arktype"
// I have some class that validates or throws. I want to parse an instance of that from a config file.
class ValidatedUserID {
static fromString(value: string): ValidatedUserID {
return new ValidatedUserID(value)
}
private constructor(readonly data: string) {}
}
const UserID = type("string")
.describe("a userID")
.pipe.try(
ValidatedUserID.fromString
)
.describe("No, really, this is a user ID")
const User = type({
id: UserID
})
const user = User.assert({
iD: "typo, oops"
})import { type } from "arktype"
// I have some class that validates or throws. I want to parse an instance of that from a config file.
class ValidatedUserID {
static fromString(value: string): ValidatedUserID {
return new ValidatedUserID(value)
}
private constructor(readonly data: string) {}
}
const UserID = type("string")
.describe("a userID")
.pipe.try(
ValidatedUserID.fromString
)
.describe("No, really, this is a user ID")
const User = type({
id: UserID
})
const user = User.assert({
iD: "typo, oops"
})Throws:
TraversalError: id must be a morph (was missing)
How can I rename this from "a morph" to a more meaningful message for users?