lincd
Version:
LINCD is a JavaScript library for building user interfaces with linked data (also known as 'structured data', or RDF)
41 lines • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkNewCount = exports.isSetModificationValue = exports.QueryFactory = void 0;
class QueryFactory {
getQueryObject() {
return null;
}
}
exports.QueryFactory = QueryFactory;
function isSetModificationValue(value) {
if (!(typeof value === 'object'))
return false;
let hasAddKey = value.$add;
let hasRemoveKey = value.$remove;
let numKeys = Object.keys(value).length;
//has no other keys
return ((hasAddKey && hasRemoveKey && numKeys === 2) ||
(hasAddKey && numKeys === 1) ||
(hasRemoveKey && numKeys === 1));
}
exports.isSetModificationValue = isSetModificationValue;
/**
* Checks if the new count of values for a property is within the min and max count of the property shape.
* Throws an error if the count is not within the range.
* @param propShape
* @param numValues
*/
function checkNewCount(propShape, numValues) {
if (propShape.maxCount) {
if (numValues > propShape.maxCount) {
throw new Error(`Too many values for property: ${propShape.label}. Max count is: ${propShape.maxCount}, updated count would be ${numValues}`);
}
}
if (propShape.minCount) {
if (numValues < propShape.minCount) {
throw new Error(`Too few values for property: ${propShape.label}. Min count is: ${propShape.minCount}, updated count would be ${numValues}`);
}
}
}
exports.checkNewCount = checkNewCount;
//# sourceMappingURL=QueryFactory.js.map