-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathutils.ts
More file actions
18 lines (16 loc) · 972 Bytes
/
utils.ts
File metadata and controls
18 lines (16 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/
import OpenShiftItem from '../../openshift/openshiftItem';
export function validateName(value: string): string | null {
let validationMessage = OpenShiftItem.emptyName('Required', value.trim());
if (!validationMessage)
validationMessage = OpenShiftItem.validateMatches(
`Please use lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character`,
value,
);
if (!validationMessage)
validationMessage = OpenShiftItem.lengthName('Should be between 2-63 characters', value, 0);
return validationMessage;
}