Result Parser Interceptor #532
Replies: 1 comment
-
This is covered by the docs here (which is not one of your links above so you may have missed it): In your client configuration object (type Once this is in place then you can use If your query returns many results and you are using const result = await pool.many(sql.type(zProductDto.strict())`
SELECT ... ;
`) See the README section on errors for the types of errors thrown in different cases including where result validation fails. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to use Slonik with Zod to validate query results.
It's a little unclear in the documentation if I need to implement my own custom Result Parser Interceptor for validation to happen.
https://github.com/gajus/slonik?tab=readme-ov-file#example-use-of-sqltype
It would appear that validation should work out-of-the-box here.
https://github.com/gajus/slonik?tab=readme-ov-file#runtime-validation
And according to step 2 here, I would need to create my own interceptor.
Does anyone know if a custom interceptor is required?
Beta Was this translation helpful? Give feedback.
All reactions