effect-http
effect-http copied to clipboard
Formatting validation errors
I realize the validation errors are coming from Schema
, but is there any way to further customize or improve upon this?
const LoginBody = S.Struct({
name: S.String,
password: S.String.pipe(S.minLength(5, {
message: () => 'My custom message'
}))
})
Error message:
{
"error": "Request validation error",
"location": "body",
"message": "{ readonly name: string; readonly password: a string at least 5 character(s) long }\n└─ [\"password\"]\n └─ My custom message"
}
Preferred:
{
"error": "Request validation error",
"location": "body",
"message": {
"password": "My custom message"
}
}