Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function stringHexColor (value: any): boolean {
if (!isString(value)) return false;
return /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i.test(value);
}
export function stringHexadecimal (value: any): boolean {
if (!isString(value)) return false;
return /^[0-9A-F]+$/i.test(value);
}
export function stringMatch (value: any, recipe: StringMatchOptions = {}): boolean {
if (!isString(value)) return false;
let { regexp } = recipe;
return regexp.test(value);
};
function stringLength(value, recipe) {
if (recipe === void 0) { recipe = {}; }
if (!typeable_1.isString(value))
return false;
var _a = recipe.bytes, bytes = _a === void 0 ? false : _a, min = recipe.min, minOrEqual = recipe.minOrEqual, max = recipe.max, maxOrEqual = recipe.maxOrEqual;
var len = bytes
? encodeURI(value).split(/%..|./).length - 1
: value.length;
if (typeable_1.isNumber(min) && !(len > min))
return false;
if (typeable_1.isNumber(minOrEqual) && !(len >= minOrEqual))
return false;
if (typeable_1.isNumber(max) && !(len < max))
return false;
if (typeable_1.isNumber(maxOrEqual) && !(len <= maxOrEqual))
return false;
return true;
}
exports.stringLength = stringLength;
function stringHexColor(value) {
if (!typeable_1.isString(value))
return false;
return /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i.test(value);
}
exports.stringHexColor = stringHexColor;
function stringMatch(value, recipe) {
if (recipe === void 0) { recipe = {}; }
if (!typeable_1.isString(value))
return false;
var regexp = recipe.regexp;
return regexp.test(value);
}
exports.stringMatch = stringMatch;
function stringHexadecimal(value) {
if (!typeable_1.isString(value))
return false;
return /^[0-9A-F]+$/i.test(value);
}
exports.stringHexadecimal = stringHexadecimal;
function stringBase64(value) {
if (!typeable_1.isString(value))
return false;
return BASE64_REGEX.test(value);
}
exports.stringBase64 = stringBase64;
.forEach(function (name) {
var field = _this._fields[name];
var value = field.cast(data[name]);
if (typeable_1.isString(strategy)
&& typeable_1.isArray(field.populatable)
&& field.populatable.indexOf(strategy) !== -1
|| !typeable_1.isString(strategy)) {
_this[name] = toValue(value);
}
});
return this;
.forEach(function (name) {
var field = _this._fields[name];
var value = field.cast(data[name]);
if (typeable_1.isString(strategy)
&& typeable_1.isArray(field.populatable)
&& field.populatable.indexOf(strategy) !== -1
|| !typeable_1.isString(strategy)) {
_this[name] = toValue(value);
}
});
return this;