effect-http icon indicating copy to clipboard operation
effect-http copied to clipboard

Formatting validation errors

Open emrosenf opened this issue 6 months ago • 3 comments

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"
    }
}

emrosenf avatar Aug 05 '24 00:08 emrosenf