While testing a command I used a variable to store my site URL so it didn't clutter my command args too much. However, I was getting a strange error as shown below:

This error was due to the fact that I made a typo and --webUrl was null (because the variable I specified didn't exist).
This is because the validator we are using is as follows:
|
isValidSharePointUrl(url: string): boolean | string { |
|
if (!url) { |
|
return false; |
|
} |
|
|
|
if (url.indexOf('https://') !== 0) { |
|
return `${url} is not a valid SharePoint Online site URL`; |
|
} |
|
else { |
|
return true; |
|
} |
|
}, |
In the command (and other commands) we validate it like this:
|
const isValidSharePointUrl: boolean | string = validation.isValidSharePointUrl(args.options.webUrl); |
|
if (isValidSharePointUrl !== true) { |
|
return isValidSharePointUrl; |
|
} |
Shouldn't we output an error message when the value is null? The current error Error: false doesn't help at all.
While testing a command I used a variable to store my site URL so it didn't clutter my command args too much. However, I was getting a strange error as shown below:
This error was due to the fact that I made a typo and
--webUrlwasnull(because the variable I specified didn't exist).This is because the validator we are using is as follows:
cli-microsoft365/src/utils/validation.ts
Lines 349 to 360 in 3152fc7
In the command (and other commands) we validate it like this:
cli-microsoft365/src/m365/spo/commands/file/file-add.ts
Lines 139 to 142 in 3152fc7
Shouldn't we output an error message when the value is
null? The current errorError: falsedoesn't help at all.