@sap-ux/project-input-validator 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -43,7 +43,10 @@
|
|
|
43
43
|
"moduleAlreadyExists": "The module folder named: {{folderName}} already exists at the specified path.",
|
|
44
44
|
"appFolderExistsAtPath": "A module with this name already exists in the folder: {{-path}}.",
|
|
45
45
|
"folderContainsFioriApp": "The project folder path already contains an SAP Fiori application in the folder: {{-path}}. Please choose a different folder and try again.",
|
|
46
|
-
"folderContainsCapApp": "The selected project folder is part of an existing CAP project. This application must use the local CAP project as the data source."
|
|
46
|
+
"folderContainsCapApp": "The selected project folder is part of an existing CAP project. This application must use the local CAP project as the data source.",
|
|
47
|
+
"viewNameRequired": "You must provide a view name to continue.",
|
|
48
|
+
"viewNameTooLong": "The view name cannot contain more than {{maxLength}} characters.",
|
|
49
|
+
"viewNameInvalid": "The view name must start with a letter and may contain letters, digits, dashes, and underscores."
|
|
47
50
|
},
|
|
48
51
|
"general": {
|
|
49
52
|
"invalidUrl": "Invalid URL: [{{-input}}]",
|
package/dist/ui5/validators.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/** Regex for a valid UI5 view name: starts with one or more letters, followed by letters/digits/underscores/hyphens. */
|
|
2
|
+
export declare const VIEW_NAME_REGEX: RegExp;
|
|
3
|
+
/** Maximum allowed length for a UI5 view name. */
|
|
4
|
+
export declare const VIEW_NAME_MAX_LENGTH = 120;
|
|
5
|
+
/**
|
|
6
|
+
* Validator: UI5 view name.
|
|
7
|
+
*
|
|
8
|
+
* @param name - view name to validate
|
|
9
|
+
* @returns true if valid, otherwise an error message string for use in Inquirer validation functions
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateViewName(name: string): boolean | string;
|
|
1
12
|
/**
|
|
2
13
|
* Validator: UI5 namespace.
|
|
3
14
|
*
|
package/dist/ui5/validators.js
CHANGED
|
@@ -2,6 +2,28 @@ import { join, posix } from 'node:path';
|
|
|
2
2
|
import { t } from '../i18n.js';
|
|
3
3
|
import { existsSync, lstatSync, accessSync, constants } from 'node:fs';
|
|
4
4
|
import validateNpmPackageName from 'validate-npm-package-name';
|
|
5
|
+
/** Regex for a valid UI5 view name: starts with one or more letters, followed by letters/digits/underscores/hyphens. */
|
|
6
|
+
export const VIEW_NAME_REGEX = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
|
7
|
+
/** Maximum allowed length for a UI5 view name. */
|
|
8
|
+
export const VIEW_NAME_MAX_LENGTH = 120;
|
|
9
|
+
/**
|
|
10
|
+
* Validator: UI5 view name.
|
|
11
|
+
*
|
|
12
|
+
* @param name - view name to validate
|
|
13
|
+
* @returns true if valid, otherwise an error message string for use in Inquirer validation functions
|
|
14
|
+
*/
|
|
15
|
+
export function validateViewName(name) {
|
|
16
|
+
if (!name) {
|
|
17
|
+
return t('ui5.viewNameRequired');
|
|
18
|
+
}
|
|
19
|
+
if (name.length > VIEW_NAME_MAX_LENGTH) {
|
|
20
|
+
return t('ui5.viewNameTooLong', { maxLength: VIEW_NAME_MAX_LENGTH });
|
|
21
|
+
}
|
|
22
|
+
if (!VIEW_NAME_REGEX.test(name)) {
|
|
23
|
+
return t('ui5.viewNameInvalid');
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
5
27
|
/**
|
|
6
28
|
* Validator: UI5 application namespace.
|
|
7
29
|
*
|