docs: function validatePatchOperationValue(
  	recordTypes, opType, opInd, pathPtr, val, forUpdate) {
  
  	// error function
  	const validate = errMsg => {
  		if (errMsg)
  			throw new common.X2SyntaxError(
  				`Invalid value in patch operation #${opInd + 1} (${opType}):` +
  					` ${errMsg}`);
  	};
  
  	// check if we have the value
  	if (val === undefined)
  		validate('no value is provided for the operation.');
  
  	// get target property descriptor
  	const propDesc = pathPtr.propDesc;
  
  	// "merge" operation is a special case
  	if (opType === 'merge') {
  
  		// value must be an object
  		if (((typeof val) !== 'object') || (val === null))
  			validate('merge value must be a non-null object.');
  
  		// target must be a single object or a whole map
  		if (!(propDesc.isMap() && !pathPtr.collectionElement) &&
  			!((propDesc.scalarValueType === 'object') && (
  				propDesc.isScalar() || pathPtr.collectionElement)))
  			validate('invalid merge target record element type.');
  
  		// valid value, return it
  		return val;
  	}
  
  	// validate if null is acceptable
  	if (val === null) {
  		if ((propDesc.isScalar() || !pathPtr.collectionElement) &&
  			!propDesc.optional)
  			validate('null for required property.');
  		if (pathPtr.collectionElement && (propDesc.scalarValueType === 'object'))
  			validate('null for nested object collection element.');
  		return val; // valid
  	}
  
  	// validate depending on the property type
  	if (propDesc.isArray() && !pathPtr.collectionElement) {
  		if (!Array.isArray(val))
  			validate('expected an array.');
  		if (!propDesc.optional && (val.length === 0))
  			validate('empty array for required property.');
  		val.forEach(v => {
  			validate(isInvalidScalarValueType(
  				recordTypes, v, propDesc, forUpdate));
  		});
  	} else if (propDesc.isMap() && !pathPtr.collectionElement) {
  		if ((typeof val) !== 'object')
  			validate('expected an object.');
  		const keys = Object.keys(val);
  		if (!propDesc.optional && (keys.length === 0))
  			validate('empty object for required property.');
  		keys.forEach(k => {
  			validate(isInvalidScalarValueType(
  				recordTypes, val[k], propDesc, forUpdate));
  		});
  	} else {
  		validate(isInvalidScalarValueType(
  			recordTypes, val, propDesc, forUpdate));
  	}
  
  	// the value is valid, return it
  	return val;
  }