From ab00aa9dbb09aefc9da051b4646a248c00482be6 Mon Sep 17 00:00:00 2001 From: Shigma Date: Tue, 7 Nov 2023 02:06:15 +0800 Subject: [PATCH] fix: incorrect impl for array / tuple simplification --- packages/core/package.json | 2 +- packages/core/src/index.ts | 12 ++++++------ packages/form/package.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index e08b461..37cc6ef 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "schemastery", "description": "Type driven schema validator", - "version": "3.14.0", + "version": "3.14.1", "main": "lib/index.cjs", "module": "lib/index.mjs", "typings": "lib/index.d.ts", diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index e377cc8..76903ee 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -108,8 +108,8 @@ declare global { default(value: T): Schema comment(text: string): Schema description(text: string): Schema - disabled(): Schema - collapse(): Schema + disabled(value?: boolean): Schema + collapse(value?: boolean): Schema deprecated(): Schema experimental(): Schema pattern(regexp: RegExp): Schema @@ -290,11 +290,11 @@ Schema.prototype.simplify = function simplify(this: Schema, value) { return result } else if (this.type === 'array' || this.type === 'tuple') { const result: any[] = [] - for (const key of value) { - const schema = this.type === 'array' ? this.inner : this.list![key] - const item = schema ? schema.simplify(value[key]) : value[key] + ;(value as any[]).forEach((value, index) => { + const schema = this.type === 'array' ? this.inner : this.list![index] + const item = schema ? schema.simplify(value) : value result.push(item) - } + }) return result } else if (this.type === 'intersect') { const result: Dict = {} diff --git a/packages/form/package.json b/packages/form/package.json index 96faae2..3bfd9ee 100644 --- a/packages/form/package.json +++ b/packages/form/package.json @@ -23,6 +23,6 @@ "vue": "^3" }, "dependencies": { - "schemastery": "^3.14.0" + "schemastery": "^3.14.1" } }