From a9a967d102a49fe6c27b2647b7c35bbf7bf88ef5 Mon Sep 17 00:00:00 2001 From: Christophe Opoix <92715621+copoix-ultra@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:27:38 +0100 Subject: [PATCH 1/2] handle bigint in unique rule --- lib/types/array.js | 1 + test/types/array.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/types/array.js b/lib/types/array.js index b7de33d7..7325bc20 100755 --- a/lib/types/array.js +++ b/lib/types/array.js @@ -496,6 +496,7 @@ module.exports = Any.extend({ number: Object.create(null), undefined: Object.create(null), boolean: Object.create(null), + bigint: Object.create(null), object: new Map(), function: new Map(), custom: new Map() diff --git a/test/types/array.js b/test/types/array.js index d09534be..ac9e1910 100755 --- a/test/types/array.js +++ b/test/types/array.js @@ -2061,7 +2061,7 @@ describe('array', () => { describe('unique()', () => { - it('errors if duplicate numbers, strings, objects, binaries, functions, dates and booleans', () => { + it('errors if duplicate numbers, strings, objects, binaries, functions, dates, booleans, bigint', () => { const buffer = Buffer.from('hello world'); const func = function () { }; @@ -2185,7 +2185,21 @@ describe('array', () => { key: 1, value: undefined } + }], + [[1n, 1n], false, { + message: '"[1]" contains a duplicate value', + path: [1], + type: 'array.unique', + context: { + pos: 1, + dupePos: 0, + dupeValue: 1n, + label: '[1]', + key: 1, + value: 1n + } }] + ]); }); From 284960bdec337d696135cc9e2ecefb7598b30d54 Mon Sep 17 00:00:00 2001 From: copoix-ultra <92715621+copoix-ultra@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:36:50 +0100 Subject: [PATCH 2/2] Update test/types/array.js --- test/types/array.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/types/array.js b/test/types/array.js index ac9e1910..39dd3c5b 100755 --- a/test/types/array.js +++ b/test/types/array.js @@ -2061,7 +2061,7 @@ describe('array', () => { describe('unique()', () => { - it('errors if duplicate numbers, strings, objects, binaries, functions, dates, booleans, bigint', () => { + it('errors if duplicate numbers, strings, objects, binaries, functions, dates, booleans and bigints', () => { const buffer = Buffer.from('hello world'); const func = function () { };