nutype icon indicating copy to clipboard operation
nutype copied to clipboard

Support custom errors

Open greyblake opened this issue 1 year ago β€’ 5 comments

Context

Some orgs and people are not quite happy with auto-generated error types, e.g. it's not possible to customize them, inject extra details, etc.

Requirement

Provide a way for users to:

  • Define and provide error type they want to use
  • Inject their custom validation function that would return Result<(), CustomError>, where CustomError is a user defined error.

Technically it's possible, but the syntax for this needs to be decided.

Consideration

Having this may clash with "unified error": https://github.com/greyblake/nutype/issues/75, so requires careful thinking.

greyblake avatar Jul 17 '24 10:07 greyblake