Skip to content

Commit 7bc8b3e

Browse files
committed
Check "number" input validity
Signed-off-by: Seb Julliand <[email protected]>
1 parent d328b72 commit 7bc8b3e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/api/CustomUI.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,13 @@ export class CustomUI extends Section {
329329
}
330330
}
331331
332+
if(field.inputType === "number"){
333+
const numberValue = Number(currentValue);
334+
isInvalid = isNaN(numberValue) ||
335+
(field.min !== undefined && numberValue < Number(field.min)) ||
336+
(field.max !== undefined && numberValue > Number(field.max));
337+
}
338+
332339
if (isInvalid) {
333340
fieldElement.setAttribute("invalid", "true");
334341
isValid = false;
@@ -578,6 +585,7 @@ export class Field {
578585
${this.maxlength ? `maxlength="${this.maxlength}"` : ``}
579586
${this.min ? `min="${this.min}"` : ``}
580587
${this.max ? `max="${this.max}"` : ``}
588+
${this.inputType === 'number' ? `step="1"` : ``}
581589
>
582590
<${tag}>
583591
</vscode-form-group>`;

0 commit comments

Comments
 (0)