The instanceof operator doesn't always work when there are multiple versions of toi in one monorepo, for example. Different require statements result in multiple ValidationError classes and the check that is performed with instanceof is no longer reliable.
One approach on how can this be fixed is by introducing a boolen flag, like isToi, to the ValidationError class that will identify the error. The Joi library has the same approach.
The
instanceofoperator doesn't always work when there are multiple versions oftoiin one monorepo, for example. Differentrequirestatements result in multipleValidationErrorclasses and the check that is performed withinstanceofis no longer reliable.One approach on how can this be fixed is by introducing a boolen flag, like
isToi, to theValidationErrorclass that will identify the error. TheJoilibrary has the same approach.