sinclairzx81 / typebox

Json Schema Type Builder with Static Type Resolution for TypeScript
Other
4.85k stars 155 forks source link

Update the error message for required properties #924

Closed mikenikles closed 2 months ago

mikenikles commented 3 months ago

Hi,

I'm in the process of upgrading from v0.25.8 to v0.32.34 and noticed one of my e2e tests failed because the error message for required properties was updated in v0.31.

It changed from Expected required property to Required property in this commit.

Are you ok with changing that back to Expected required property to align it with the other error messages? If so, I'll open a PR.

sinclairzx81 commented 2 months ago

@mikenikles Hi, Apologies for the delay in reply (have been exceptionally busy of late)

I am happy to receive a PR to amend/revert this message, however it may be worthwhile checking out the TypeBox error function.

https://github.com/sinclairzx81/typebox?tab=readme-ov-file#error-function

Usually it's better to intercept the ValueErrorType enumeration than the en-US string message, however I'm not sure if this would work with your current implementation. The error function has been updated since 0.25.x so it might be good to check none the less.

Will keep this issue open for a week or so if you wanted to submit the PR to revert the message. Again, sorry for the delay. S

sinclairzx81 commented 2 months ago

@mikenikles Hiya,

Have just published a update to amend the error message on 0.32.35. You should be able to use this moving forward, but would recommend investigating the ValueErrorType passed on the ErrorFunction for more robust matching.

Hope this helps S

mikenikles commented 2 months ago

Thanks a lot for the change and also the link to the custom error handling 🙏.