Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getPath = (path, parseInteger = true) => {
if (isPath(path)) return path
let result = path
if (is.function(result)) {
result = getPath(result(), parseInteger)
}
if (!is.existy(result)) return result
if (is.array(result)) {
result = map(partialRight(getPath, [parseInteger]), result)
}
if (is.string(result)) {
result = pathSplit(result)
if (parseInteger && result) result = mapIndexes(result)
}
if (is.integer(result)) result = [result]
return flattenFilter(result)
},
toLens = lensPath,
export const isIntOrDecimal = (name, value) => ({
isValid: is.integer(value * 1) || is.decimal(value * 1),
errorText: `${name} should be either integer or decimal.`
});
export const isInt = (name, value) => ({
isValid: is.integer(value * 1),
errorText: `${name} should be integer.`
});
getNumber (key, defaultVal) {
const value = this.get(key, defaultVal)
const intVal = parseInt(value, 10)
const valIsInt = is.integer(intVal)
if (value === defaultVal) {
return value
} else if (valIsInt) {
return intVal
}
},
export function isIntHandler(value, schema) {
const isValid = is.integer(value * 1);
if (isValid) return;
const errorText = `${NAME_PLACEHOLDER} should be integer.`;
throwError(value, errorText);
}
conditionProps.forEach(p => {
if (r.condition[p]) {
if (p === 'httpErrorCodeReturnedEquals') {
if (!is.integer(r.condition[p])) {
validationErrors.push('httpErrorCodeReturnedEquals must be an integer');
}
} else {
if (!is.string(r.condition[p])) {
validationErrors.push(`${p} must be a string`);
}
}
}
});
}
isPathItemValid = (p) => {
let result = is.string(p) && p.indexOf('.') === -1
if (isIndex(p)) result = result && is.integer(p)
return result
},
areAllItemsValid = all(isPathItemValid),