Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const validateReferenceArgs = (guid, property, reference) => {
if (!_.isNonEmptyString(guid)) {
throw error_.new('missing guid', 400, guid)
}
const [ entity, rest ] = guid.split('$')
if (!wdk.isItemId(entity)) {
throw error_.new('invalid guid', 400, guid)
}
if (!(_.isNonEmptyString(rest) && /[\w-]{36}/.test(rest))) {
throw error_.new('invalid guid', 400, guid)
}
if (!_.isNonEmptyString(property)) {
throw error_.new('missing property', 400, property)
}
validate.property(property)
validate.referenceValue(property, reference)
}
const validateClaim = claim => {
const [ P, Q ] = claim.split(':')
if (!(isPropertyId(P))) throw new Error(`invalid claim property: ${P}`)
if (Q) {
const Qs = Q.split(',')
for (let q of Qs) {
if (!(isItemId(q))) throw new Error(`invalid claim value: ${q}`)
}
}
}