Bobakanoosh
Bobakanoosh
Explore posts from servers
Aarktype
Created by Bobakanoosh on 10/2/2024 in #questions
Customizing Error Messages
I've searched Github & Discord a bit and seen a few mentions of "full error customization", and am finding that I need it, but can't find any examples of it. I have a type:
const form = type({
user: {
email: 'string.email',
age: 'number>13',
}
})
const form = type({
user: {
email: 'string.email',
age: 'number>13',
}
})
When these fields are incorrect, it yields the following error messages:
{
"user.email": "user.email must be an email address (was \"test\")",
"user.age": "user.age must be more than 13 (was 12)"
}
{
"user.email": "user.email must be an email address (was \"test\")",
"user.age": "user.age must be more than 13 (was 12)"
}
I want to show these outputs in-line in a form. To do that, I need some more customization like: - Showing email instead of user.email (I can use css capitalize to capitalize it if necessary) - Getting rid of (was ___) Right now my best option is to manually manipulate the string to make these changes, which isn't ideal.
5 replies
Aarktype
Created by Bobakanoosh on 10/2/2024 in #questions
v2 docs
I see the v2 docs mentioned frequently here and in GitHub, but I can’t find a link to them. Are they deployed? Even if they’re a WIP, they’d be extremely valuable to have I think
2 replies