Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sap-ux/project-input-validator

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap-ux/project-input-validator - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

dist/adp/validators.d.ts

29

dist/general/validators.d.ts

@@ -15,2 +15,31 @@ /**

export declare function validateUrl(input: string): boolean | string;
/**
* Validate input is not empty string.
*
* @param input input string to be validated
* @returns true or error message
*/
export declare function validateEmptyString(input: string): boolean | string;
/**
* Validate input does not contain any whitespace characters.
*
* @param value The string to check for whitespace characters.
* @returns true or error message
*/
export declare function validateEmptySpaces(value: string): boolean | string;
/**
* Validate input is valid JSON.
*
* @param value The string to test.
* @returns true or error message
*/
export declare function validateJSON(value: string): boolean | string;
/**
* Validates a value for special characters.
*
* @param value The value to validate.
* @param regexp The regex expression for allowed special characters.
* @returns {boolean} True if validation passes, or an error message if validation fails.
*/
export declare function validateSpecialChars(value: string, regexp?: string): boolean | string;
//# sourceMappingURL=validators.d.ts.map

60

dist/general/validators.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateUrl = exports.validateClient = void 0;
exports.validateSpecialChars = exports.validateJSON = exports.validateEmptySpaces = exports.validateEmptyString = exports.validateUrl = exports.validateClient = void 0;
const i18n_1 = require("../i18n");

@@ -38,2 +38,60 @@ /**

exports.validateUrl = validateUrl;
/**
* Validate input is not empty string.
*
* @param input input string to be validated
* @returns true or error message
*/
function validateEmptyString(input) {
const formattedInput = input?.trim() || '';
if (formattedInput.trim().length > 0) {
return true;
}
return (0, i18n_1.t)('general.inputCannotBeEmpty');
}
exports.validateEmptyString = validateEmptyString;
/**
* Validate input does not contain any whitespace characters.
*
* @param value The string to check for whitespace characters.
* @returns true or error message
*/
function validateEmptySpaces(value) {
if (/\s/.test(value)) {
return (0, i18n_1.t)('general.inputCannotHaveSpaces');
}
return true;
}
exports.validateEmptySpaces = validateEmptySpaces;
/**
* Validate input is valid JSON.
*
* @param value The string to test.
* @returns true or error message
*/
function validateJSON(value) {
try {
JSON.parse(`{${value}}`);
return true;
}
catch {
return (0, i18n_1.t)('general.invalidJSON');
}
}
exports.validateJSON = validateJSON;
/**
* Validates a value for special characters.
*
* @param value The value to validate.
* @param regexp The regex expression for allowed special characters.
* @returns {boolean} True if validation passes, or an error message if validation fails.
*/
function validateSpecialChars(value, regexp = '^[a-zA-Z0-9_$.\\-]+$') {
const regex = new RegExp(regexp, 'g');
if (regex.test(value)) {
return true;
}
return (0, i18n_1.t)('general.invalidValueForSpecialChars');
}
exports.validateSpecialChars = validateSpecialChars;
//# sourceMappingURL=validators.js.map
export * from './deploy/validators';
export * from './ui5/validators';
export * from './general/validators';
export * from './adp/validators';
//# sourceMappingURL=index.d.ts.map

@@ -20,2 +20,3 @@ "use strict";

__exportStar(require("./general/validators"), exports);
__exportStar(require("./adp/validators"), exports);
//# sourceMappingURL=index.js.map

@@ -47,4 +47,8 @@ {

"invalidUrl": "Invalid URL: [{{-input}}]",
"invalidClient": "[{{client}}] is invalid. Leave empty or enter value between 000-999"
"invalidClient": "[{{client}}] is invalid. Leave empty or enter value between 000-999",
"inputCannotBeEmpty": "Input cannot be empty.",
"inputCannotHaveSpaces": "Input cannot contain spaces.",
"invalidJSON": "Invalid JSON",
"invalidValueForSpecialChars": "Input must contain only Latin alphanumeric characters or the following symbols: '-','_','$' and '.'"
}
}

2

package.json
{
"name": "@sap-ux/project-input-validator",
"version": "0.3.1",
"version": "0.3.2",
"description": "Library to validate Fiori project input formats",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc