Skip to content

Commit 5b96852

Browse files
authored
fix: handle bigint in unique rule (#3026)
1 parent e7e9c5d commit 5b96852

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/types/array.js

+1
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ module.exports = Any.extend({
496496
number: Object.create(null),
497497
undefined: Object.create(null),
498498
boolean: Object.create(null),
499+
bigint: Object.create(null),
499500
object: new Map(),
500501
function: new Map(),
501502
custom: new Map()

test/types/array.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,7 @@ describe('array', () => {
20612061

20622062
describe('unique()', () => {
20632063

2064-
it('errors if duplicate numbers, strings, objects, binaries, functions, dates and booleans', () => {
2064+
it('errors if duplicate numbers, strings, objects, binaries, functions, dates, booleans and bigints', () => {
20652065

20662066
const buffer = Buffer.from('hello world');
20672067
const func = function () { };
@@ -2185,7 +2185,21 @@ describe('array', () => {
21852185
key: 1,
21862186
value: undefined
21872187
}
2188+
}],
2189+
[[1n, 1n], false, {
2190+
message: '"[1]" contains a duplicate value',
2191+
path: [1],
2192+
type: 'array.unique',
2193+
context: {
2194+
pos: 1,
2195+
dupePos: 0,
2196+
dupeValue: 1n,
2197+
label: '[1]',
2198+
key: 1,
2199+
value: 1n
2200+
}
21882201
}]
2202+
21892203
]);
21902204
});
21912205

0 commit comments

Comments
 (0)