data-validator-js
Version:
Validation Methods for all types of Data
71 lines (70 loc) • 2.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var StringUtilities = /** @class */ (function () {
function StringUtilities() {
}
Object.defineProperty(StringUtilities, "EmptyString", {
/**
* Empty string
*/
get: function () {
return '';
},
enumerable: true,
configurable: true
});
/**
* Is True string
*/
StringUtilities.IsTrue = function (value) {
var returnValue = false;
try {
returnValue = eval(value.toLowerCase());
}
catch (e) {
returnValue = false;
}
return returnValue;
};
Object.defineProperty(StringUtilities, "WhiteSpace", {
/**
* Whitespace
*/
get: function () {
return / /g;
},
enumerable: true,
configurable: true
});
Object.defineProperty(StringUtilities, "EnglishAndNumericCharacters", {
get: function () {
return /([a-z0-9A-Z]+)/g;
},
enumerable: true,
configurable: true
});
/**
* Checks string is null,undefined or empty.
* @param str string for which we need to check.
*/
StringUtilities.IsNullOrEmpty = function (str) {
return str === null || str === undefined || str === '';
};
/**
* Checks if the main string ends with the sub string
* @param mainString The main string, in which sub string needs to be searched
* @param subString The smaller string that is to be searched
*/
StringUtilities.EndsWithString = function (mainString, subString) {
return mainString.indexOf(subString, mainString.length - subString.length) !== -1;
};
/**
* Checks if string contains only spaces, tabs or line breaks.
* @param str string for which we need to check
*/
StringUtilities.IsBlankString = function (str) {
return str.replace(/\s/g, '').length === 0;
};
return StringUtilities;
}());
exports.default = StringUtilities;