Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validationUtils Azure tools migration #582

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { type ContainerAppsAPIClient } from "@azure/arm-appcontainers";
import { AzureWizardPromptStep, nonNullValueAndProp, type ISubscriptionActionContext } from "@microsoft/vscode-azext-utils";
import { AzureWizardPromptStep, nonNullValueAndProp, validationUtils, type ISubscriptionActionContext } from "@microsoft/vscode-azext-utils";
import { createContainerAppsAPIClient } from "../../utils/azureClients";
import { localize } from "../../utils/localize";
import { type IManagedEnvironmentContext } from './IManagedEnvironmentContext';
Expand All @@ -28,11 +28,13 @@
private validateInput(name: string | undefined): string | undefined {
name = name ? name.trim() : '';

const { minLength, maxLength } = { minLength: 4, maxLength: 20 };
const rc: validationUtils.RangeConstraints = { lowerLimitIncl: 4, upperLimitIncl: 20 };
if (!validationUtils.hasValidCharLength(name, rc)) {

Check failure on line 32 in src/commands/createManagedEnvironment/ManagedEnvironmentNameStep.ts

View workflow job for this annotation

GitHub Actions / Build / Build

Unsafe member access .hasValidCharLength on an `any` value

Check failure on line 32 in src/commands/createManagedEnvironment/ManagedEnvironmentNameStep.ts

View workflow job for this annotation

GitHub Actions / Build / Build

Unsafe call of an `any` typed value
return validationUtils.getInvalidCharLengthMessage(rc);

Check failure on line 33 in src/commands/createManagedEnvironment/ManagedEnvironmentNameStep.ts

View workflow job for this annotation

GitHub Actions / Build / Build

Unsafe return of an `any` typed value

Check failure on line 33 in src/commands/createManagedEnvironment/ManagedEnvironmentNameStep.ts

View workflow job for this annotation

GitHub Actions / Build / Build

Unsafe member access .getInvalidCharLengthMessage on an `any` value

Check failure on line 33 in src/commands/createManagedEnvironment/ManagedEnvironmentNameStep.ts

View workflow job for this annotation

GitHub Actions / Build / Build

Unsafe call of an `any` typed value
}

if (!/^[a-z]([-a-z0-9]*[a-z0-9])?$/.test(name)) {
return localize('invalidChar', `A name must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character and cannot have '--'.`);
} else if ((name.length < minLength) || name.length > maxLength) {
return localize('invalidLength', 'The name must be between {0} and {1} characters.', minLength, maxLength);
}

return undefined;
Expand Down
Loading