Skip to content

Commit

Permalink
Check "number" input validity
Browse files Browse the repository at this point in the history
Signed-off-by: Seb Julliand <[email protected]>
  • Loading branch information
sebjulliand committed Jan 5, 2025
1 parent d328b72 commit 7bc8b3e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/api/CustomUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,13 @@ export class CustomUI extends Section {
}
}
if(field.inputType === "number"){
const numberValue = Number(currentValue);
isInvalid = isNaN(numberValue) ||
(field.min !== undefined && numberValue < Number(field.min)) ||
(field.max !== undefined && numberValue > Number(field.max));
}
if (isInvalid) {
fieldElement.setAttribute("invalid", "true");
isValid = false;
Expand Down Expand Up @@ -578,6 +585,7 @@ export class Field {
${this.maxlength ? `maxlength="${this.maxlength}"` : ``}
${this.min ? `min="${this.min}"` : ``}
${this.max ? `max="${this.max}"` : ``}
${this.inputType === 'number' ? `step="1"` : ``}
>
<${tag}>
</vscode-form-group>`;
Expand Down

0 comments on commit 7bc8b3e

Please sign in to comment.