Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### Unreleased

Don't run uniqueItems validator if set to false

### 2.15.2

- Support drag and drop for array item
Expand Down
1 change: 1 addition & 0 deletions src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ export class Validator {
return []
},
uniqueItems (schema, value, path) {
if (schema.uniqueItems === false) return []
const seen = {}
for (let i = 0; i < value.length; i++) {
const valid = JSON.stringify(value[i])
Expand Down
2 changes: 1 addition & 1 deletion tests/codeceptjs/editors/validation_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature('Validations')

Scenario('test validations in validation.html', ({ I }) => {
I.amOnPage('validation.html')
const numberOfTestItemsExpected = 158
const numberOfTestItemsExpected = 161
I.waitForElement('#output div:nth-child(' + numberOfTestItemsExpected + ')', DEFAULT_WAIT_TIME)
I.seeNumberOfElements('#output div', numberOfTestItemsExpected)
I.see('success')
Expand Down
31 changes: 31 additions & 0 deletions tests/fixtures/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,37 @@
]
]
},
"uniqueItems_false": {
"schema": {
"uniqueItems": false
},
"valid": [
[
1,
2,
3,
{
"a": 1
},
"1",
"{a:1}"
],
[
1,
1,
2
],
[
{
"a": 1
},
{
"a": 1
}
]
],
"invalid": []
},
"minmaxProperties": {
"schema": {
"type": "object",
Expand Down
Loading