Skip to content

Commit

Permalink
fix(json-schema): handled nested key for uniqueItems
Browse files Browse the repository at this point in the history
fix #3842
  • Loading branch information
aitboudad committed Jan 7, 2024
1 parent 55512fb commit 0f67d89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/core/json-schema/src/formly-json-schema.service.spec.ts
Expand Up @@ -430,6 +430,8 @@ describe('Service: FormlyJsonschema', () => {
{ b: 1, a: 2 },
]),
).toBeFalse();

expect(uniqueItemsValidator([{ foo: { a: 2, b: 1 } }, { foo: { b: 1, a: 2 } }])).toBeFalse();
expect(uniqueItemsValidator([{ a: 2 }, { a: 1 }])).toBeTrue();
expect(uniqueItemsValidator([{ a: 1 }, { a: 1 }])).toBeFalse();
});
Expand Down
4 changes: 2 additions & 2 deletions src/core/json-schema/src/formly-json-schema.service.ts
Expand Up @@ -369,10 +369,10 @@ export class FormlyJsonschema {
value.map((v: any) =>
JSON.stringify(v, (k, o) => {
if (isObject(o)) {
return Object.keys(v)
return Object.keys(o)
.sort()
.reduce((obj: any, key) => {
obj[key] = v[key];
obj[key] = o[key];
return obj;
}, {});
}
Expand Down

0 comments on commit 0f67d89

Please sign in to comment.