mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-02-21 09:43:57 +08:00
parent
ffd55c532c
commit
e930d0c3f3
1 changed files with 14 additions and 10 deletions
|
|
@ -254,17 +254,21 @@ async function apply(): Promise<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
const noPresetName: boolean =
|
||||
["add", "edit"].includes(action) &&
|
||||
presetName.replace(/^_+|_+$/g, "").length === 0; //all whitespace names are rejected
|
||||
if (noPresetName) {
|
||||
Notifications.add("Preset name cannot be empty", 0);
|
||||
return;
|
||||
}
|
||||
const addOrEditAction = action === "add" || action === "edit";
|
||||
if (addOrEditAction) {
|
||||
//validate the preset name only in add or edit mode
|
||||
|
||||
if (presetNameEl?.getValidationResult().status === "failed") {
|
||||
Notifications.add("Preset name is not valid", 0);
|
||||
return;
|
||||
const noPresetName: boolean =
|
||||
presetName.replace(/^_+|_+$/g, "").length === 0; //all whitespace names are rejected
|
||||
if (noPresetName) {
|
||||
Notifications.add("Preset name cannot be empty", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (presetNameEl?.getValidationResult().status === "failed") {
|
||||
Notifications.add("Preset name is not valid", 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
hide();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue