Skip to content

Commit

Permalink
fix: handle bigint in unique rule (#3026)
Browse files Browse the repository at this point in the history
  • Loading branch information
copoix-ultra authored and Marsup committed Apr 3, 2024
1 parent d279aa0 commit 0dfd48f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/types/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,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()
Expand Down
16 changes: 15 additions & 1 deletion test/types/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 and bigints', () => {

const buffer = Buffer.from('hello world');
const func = function () { };
Expand Down Expand Up @@ -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
}
}]

]);
});

Expand Down

0 comments on commit 0dfd48f

Please sign in to comment.