You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Community
is this issue currently blocking your project? (yes/no): no
is this issue affecting a production system? (yes/no): yes
Context
node version: 12.14.1
module version with issue: 16.1.1
last module version without issue: 16.0.1
environment (e.g. node, browser, native): node
used with (e.g. hapi application, another framework, standalone, ...): standalone
any other relevant information:
What are you trying to achieve or the steps to reproduce?
I am trying validate that an array contains an Error.
/** run the next tests by ./node_modules/jest/bin/jest.js joi.test.js */constJoi=require('@hapi/joi');constErrorSchema=Joi.object().instance(Error)constCustomErrorSchema=Joi.any().custom((error)=>{if(errorinstanceofError){returntrue;}thrownewError('Error validation fail');}).raw(true);constcreateArraySchema=(...items)=>Joi.array().items(...items);it('1# should pass validation of Error schema',()=>{expect(ErrorSchema.validate(newError('test error'))).toEqual({value: newError('test error')});});it('2# should pass validation of Error schema in array',()=>{expect(createArraySchema(ErrorSchema).validate([newError('test error')])).toEqual({value: [newError('test error')]});});it('3# should pass validation of Error schema in array (workaround)',()=>{expect(createArraySchema(CustomErrorSchema.raw(false)).raw(true).validate([newError('test error')])).toEqual({value: [newError('test error')]});});
What was the result you got?
Test 2# fails due to validation always fails even though the Error is valid item of the array.
What result did you expect?
Array item could be an Error.
I see the #2118 where this issue was introduced. Due to missing description there I created this issue.
The text was updated successfully, but these errors were encountered:
I'm marking this as a breaking change (released as a non-breaking version) because it is possible someone has written an extension that uses this bug to send multiple errors from a custom rule using an array. If that's the case, this will break that because it now requires a special array generated by helpers.errorsArray(). Since this wasn't documented and was a bug, I am releasing this as a non-breaking release.
Support plan
Context
What are you trying to achieve or the steps to reproduce?
I am trying validate that an array contains an Error.
What was the result you got?
Test 2# fails due to validation always fails even though the Error is valid item of the array.
What result did you expect?
Array item could be an Error.
I see the #2118 where this issue was introduced. Due to missing description there I created this issue.
The text was updated successfully, but these errors were encountered: