From 43b39502df35bb317da9346eb9630d1d5fefe40c Mon Sep 17 00:00:00 2001 From: David Ayre Date: Tue, 3 May 2022 19:09:05 -0700 Subject: [PATCH 1/8] Restore minLength and maxLength support to HAL FORMS parsing Restored parsing of minLength and maxLength for use in input and textarea fields. --- src/state/hal.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/state/hal.ts b/src/state/hal.ts index f0feb02..7648f29 100644 --- a/src/state/hal.ts +++ b/src/state/hal.ts @@ -335,6 +335,8 @@ function parseHalField(halField: hal.HalFormsProperty): Field { pattern: halField.regex ? new RegExp(halField.regex) : undefined, label: halField.prompt, placeholder: halField.placeHolder, + minLength: halField.minLength, + maxLength: halField.maxLength, }; } case 'hidden' : @@ -346,6 +348,8 @@ function parseHalField(halField: hal.HalFormsProperty): Field { value: halField.value, label: halField.prompt, placeholder: halField.placeHolder, + minLength: halField.minLength, + maxLength: halField.maxLength, }; case 'textarea' : return { @@ -358,6 +362,8 @@ function parseHalField(halField: hal.HalFormsProperty): Field { placeholder: halField.placeHolder, cols: halField.cols, rows: halField.rows, + minLength: halField.minLength, + maxLength: halField.maxLength, }; case 'password' : return { @@ -367,6 +373,8 @@ function parseHalField(halField: hal.HalFormsProperty): Field { readOnly: halField.readOnly || false, label: halField.prompt, placeholder: halField.placeHolder, + minLength: halField.minLength, + maxLength: halField.maxLength, }; case 'date' : case 'month' : From e75e3757d1960ed5aaf0477168e085ad33a9dafc Mon Sep 17 00:00:00 2001 From: David Ayre Date: Tue, 3 May 2022 22:04:24 -0700 Subject: [PATCH 2/8] Added minLength and maxLength to HiddenField interface --- src/field.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/field.ts b/src/field.ts index ed2513d..2f71be6 100644 --- a/src/field.ts +++ b/src/field.ts @@ -94,6 +94,8 @@ interface DateTimeField extends RangeField { interface HiddenField extends BaseField { type: 'hidden'; + minLength?: number; + maxLength?: number; } interface FileField extends BaseField { From 1ebd5340384cd1832ae4492d1ff98596daf31b4a Mon Sep 17 00:00:00 2001 From: David Ayre Date: Tue, 3 May 2022 22:20:09 -0700 Subject: [PATCH 3/8] Added minLength and maxLength to BasicStringField --- src/field.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/field.ts b/src/field.ts index 2f71be6..ebc4410 100644 --- a/src/field.ts +++ b/src/field.ts @@ -82,6 +82,8 @@ interface BooleanField extends BaseField { */ interface BasicStringField extends BaseField { type: 'color' | 'email' | 'password' | 'search' | 'tel' | 'url'; + minLength?: number; + maxLength?: number; } interface RangeStringField extends RangeField { From 55c6253f66122c2c4468c43a5d5a1f2d5639a362 Mon Sep 17 00:00:00 2001 From: David Ayre Date: Tue, 10 May 2022 14:47:43 -0700 Subject: [PATCH 4/8] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d9d9946..05b2b40 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "types": "dist/index.d.ts", "dependencies": { "fetch-mw-oauth2": "^1.0.0", - "hal-types": "^1.7.4", + "hal-types": "^1.7.7", "http-link-header": "^1.0.3", "node-fetch": "^2.6.1", "querystring-browser": "^1.0.4", From 1d753ddd67eaf4910ba1c0723176903921448c21 Mon Sep 17 00:00:00 2001 From: David Ayre Date: Tue, 10 May 2022 18:38:28 -0700 Subject: [PATCH 5/8] Update package-lock.json --- package-lock.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 225dbbb..319a225 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "fetch-mw-oauth2": "^1.0.0", - "hal-types": "^1.7.4", + "hal-types": "^1.7.7", "http-link-header": "^1.0.3", "node-fetch": "^2.6.1", "querystring-browser": "^1.0.4", @@ -2827,9 +2827,9 @@ } }, "node_modules/hal-types": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/hal-types/-/hal-types-1.7.4.tgz", - "integrity": "sha512-MXIm5IbUZJ+gr6hhXvf0FH59eNDgSW4UbDip4Pv/9sa6gHlVQUbO+tYl0CsD26jN5lw3TgIbcFoi4frcS4jPdg==" + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/hal-types/-/hal-types-1.7.7.tgz", + "integrity": "sha512-o1MG92pVxrehRk2tH3rJnpMad7Hg78tuyDN7oSlQ5VNczJrjL/AGIdm/biwi0gUOxZdFuN1mdKHklP0IBguIOA==" }, "node_modules/has": { "version": "1.0.3", @@ -8017,9 +8017,9 @@ "dev": true }, "hal-types": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/hal-types/-/hal-types-1.7.4.tgz", - "integrity": "sha512-MXIm5IbUZJ+gr6hhXvf0FH59eNDgSW4UbDip4Pv/9sa6gHlVQUbO+tYl0CsD26jN5lw3TgIbcFoi4frcS4jPdg==" + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/hal-types/-/hal-types-1.7.7.tgz", + "integrity": "sha512-o1MG92pVxrehRk2tH3rJnpMad7Hg78tuyDN7oSlQ5VNczJrjL/AGIdm/biwi0gUOxZdFuN1mdKHklP0IBguIOA==" }, "has": { "version": "1.0.3", From 1acdc54f2aefbbbcce9fa47f531c2fff9c2db74b Mon Sep 17 00:00:00 2001 From: David Ayre Date: Tue, 10 May 2022 20:02:40 -0700 Subject: [PATCH 6/8] Update hal-forms.ts --- test/unit/state/hal-forms.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/unit/state/hal-forms.ts b/test/unit/state/hal-forms.ts index 8233afc..8495950 100644 --- a/test/unit/state/hal-forms.ts +++ b/test/unit/state/hal-forms.ts @@ -163,6 +163,8 @@ describe('HAL forms', () => { label: undefined, pattern: undefined, placeholder: undefined, + maxLength: undefined, + minLength: undefined, value: undefined, } ], @@ -232,6 +234,8 @@ describe('HAL forms', () => { label: undefined, pattern: undefined, placeholder: undefined, + maxLength: undefined, + minLength: undefined, value: undefined, } ], From 1515911d80d5c615b8aa03094a59a3112fa4e1c8 Mon Sep 17 00:00:00 2001 From: David Ayre Date: Wed, 11 May 2022 08:52:25 -0700 Subject: [PATCH 7/8] Update field.ts Removed minLength/maxLength attributes for input type=hidden per RFC --- src/field.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/field.ts b/src/field.ts index ebc4410..95892b5 100644 --- a/src/field.ts +++ b/src/field.ts @@ -96,8 +96,6 @@ interface DateTimeField extends RangeField { interface HiddenField extends BaseField { type: 'hidden'; - minLength?: number; - maxLength?: number; } interface FileField extends BaseField { From 76be35fd2f138436a189966e0333bc3366a0c711 Mon Sep 17 00:00:00 2001 From: David Ayre Date: Wed, 11 May 2022 08:54:42 -0700 Subject: [PATCH 8/8] Update hal.ts Removed minlength/maxlength from input type=hidden per RFC --- src/state/hal.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/state/hal.ts b/src/state/hal.ts index 7648f29..7456a90 100644 --- a/src/state/hal.ts +++ b/src/state/hal.ts @@ -348,8 +348,6 @@ function parseHalField(halField: hal.HalFormsProperty): Field { value: halField.value, label: halField.prompt, placeholder: halField.placeHolder, - minLength: halField.minLength, - maxLength: halField.maxLength, }; case 'textarea' : return {