@sap-ux/project-input-validator
Advanced tools
Comparing version 0.2.3 to 0.3.0
@@ -92,3 +92,3 @@ "use strict"; | ||
const regex = /^[$LlTt]/; | ||
if (!regex.test(packageName) && !(transportRequest === null || transportRequest === void 0 ? void 0 : transportRequest.trim())) { | ||
if (!regex.test(packageName) && !transportRequest?.trim()) { | ||
return (0, i18n_1.t)('deploy.abapTransportNumRequired'); | ||
@@ -108,3 +108,3 @@ } | ||
function validatePackage(input) { | ||
if (!(input === null || input === void 0 ? void 0 : input.trim())) { | ||
if (!input?.trim()) { | ||
return (0, i18n_1.t)('deploy.abapPackageWarn'); | ||
@@ -111,0 +111,0 @@ } |
@@ -12,3 +12,3 @@ "use strict"; | ||
function validateClient(client) { | ||
const formattedInput = (client === null || client === void 0 ? void 0 : client.trim()) || ''; | ||
const formattedInput = client?.trim() || ''; | ||
const isValid = formattedInput === '' || /^\d{3}$/.test(formattedInput); | ||
@@ -34,3 +34,3 @@ if (isValid) { | ||
} | ||
catch (_a) { | ||
catch { | ||
return (0, i18n_1.t)('general.invalidUrl', { input }); | ||
@@ -37,0 +37,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -22,6 +13,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
*/ | ||
function initI18nProjectValidators() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', exports.PROJECT_INPUT_VALIDATOR_NS, project_input_validator_i18n_json_1.default)); | ||
}); | ||
async function initI18nProjectValidators() { | ||
await i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', exports.PROJECT_INPUT_VALIDATOR_NS, project_input_validator_i18n_json_1.default)); | ||
} | ||
@@ -37,4 +26,4 @@ exports.initI18nProjectValidators = initI18nProjectValidators; | ||
function t(key, options) { | ||
if (!(options === null || options === void 0 ? void 0 : options.ns)) { | ||
options = Object.assign(options !== null && options !== void 0 ? options : {}, { ns: exports.PROJECT_INPUT_VALIDATOR_NS }); | ||
if (!options?.ns) { | ||
options = Object.assign(options ?? {}, { ns: exports.PROJECT_INPUT_VALIDATOR_NS }); | ||
} | ||
@@ -41,0 +30,0 @@ return i18next_1.default.t(key, options); |
@@ -115,10 +115,9 @@ "use strict"; | ||
function validateModuleName(moduleName) { | ||
var _a, _b; | ||
if (/^[^a-zA-Z]/.test(moduleName)) { | ||
return (0, i18n_1.t)('ui5.moduleNameMustStartWithLetter'); | ||
} | ||
if ((moduleName === null || moduleName === void 0 ? void 0 : moduleName.length) > 70) { | ||
if (moduleName?.length > 70) { | ||
return (0, i18n_1.t)('ui5.nameTooLong', { length: 70 }); | ||
} | ||
if ((moduleName === null || moduleName === void 0 ? void 0 : moduleName.length) < 3) { | ||
if (moduleName?.length < 3) { | ||
return (0, i18n_1.t)('ui5.nameTooShort', { length: 3 }); | ||
@@ -148,5 +147,5 @@ } | ||
} | ||
return [...((_a = valid.errors) !== null && _a !== void 0 ? _a : []), ...((_b = valid.warnings) !== null && _b !== void 0 ? _b : [])] | ||
return [...(valid.errors ?? []), ...(valid.warnings ?? [])] | ||
.filter((msg) => !!msg) | ||
.map((msg) => { var _a; return (_a = messageMap[msg]) !== null && _a !== void 0 ? _a : (0, i18n_1.t)('ui5.invalidModuleName'); }) | ||
.map((msg) => messageMap[msg] ?? (0, i18n_1.t)('ui5.invalidModuleName')) | ||
.join(', '); | ||
@@ -153,0 +152,0 @@ } |
{ | ||
"name": "@sap-ux/project-input-validator", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "Library to validate Fiori project input formats", | ||
@@ -23,3 +23,3 @@ "repository": { | ||
"@types/i18next": "13.0.0", | ||
"jest-extended": "3.2.4" | ||
"jest-extended": "4.0.2" | ||
}, | ||
@@ -26,0 +26,0 @@ "files": [ |
36188
524