lincd
Version:
LINCD is a JavaScript library for building user interfaces with linked data (also known as 'structured data', or RDF)
35 lines • 1.27 kB
JavaScript
export class QueryFactory {
getQueryObject() {
return null;
}
}
export 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));
}
/**
* 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
*/
export 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}`);
}
}
}
//# sourceMappingURL=QueryFactory.js.map