lib/standard.js
function hasMatchingSibling(ctx, propName, testValue, whenErrors) {

	const containerDesc = ctx.currentPropDesc.container;
	const propDesc = containerDesc.getPropertyDesc(propName);

	let propPtr;
	if (containerDesc.parentContainer &&
		containerDesc.parentContainer.isPolymorphObject()) {
		const pathParts = containerDesc.nestedPath.split('.');
		propPtr = ctx.currentPointer.parent.createChildPointer(
			`${pathParts[pathParts.length - 2]}:${propName}`);
	} else {
		propPtr = ctx.currentPointer.parent.createChildPointer(propName);
	}

	if (ctx.hasErrorsFor(propPtr))
		return whenErrors;

	const container = ctx.containersChain[ctx.containersChain.length - 1];
	const propValue = container[propName];
	if (testValue !== undefined) {
		if (((testValue instanceof RegExp) && testValue.test(propValue)) ||
			(propValue === testValue))
			return true;
	} else {
		if (!isEmpty(propPtr, propDesc, propValue))
			return true;
	}

	return false;
}
function hasMatchingSibling(ctx, propName, testValue, whenErrors) {

	const containerDesc = ctx.currentPropDesc.container;
	const propDesc = containerDesc.getPropertyDesc(propName);

	let propPtr;
	if (containerDesc.parentContainer &&
		containerDesc.parentContainer.isPolymorphObject()) {
		const pathParts = containerDesc.nestedPath.split('.');
		propPtr = ctx.currentPointer.parent.createChildPointer(
			`${pathParts[pathParts.length - 2]}:${propName}`);
	} else {
		propPtr = ctx.currentPointer.parent.createChildPointer(propName);
	}

	if (ctx.hasErrorsFor(propPtr))
		return whenErrors;

	const container = ctx.containersChain[ctx.containersChain.length - 1];
	const propValue = container[propName];
	if (testValue !== undefined) {
		if (((testValue instanceof RegExp) && testValue.test(propValue)) ||
			(propValue === testValue))
			return true;
	} else {
		if (!isEmpty(propPtr, propDesc, propValue))
			return true;
	}

	return false;
}
function hasMatchingSibling ( ctx , propName , testValue , whenErrors ) { const containerDesc = ctx . currentPropDesc . container ; const propDesc = containerDesc . getPropertyDesc ( propName ) ; let propPtr ; if ( containerDesc . parentContainer && containerDesc . parentContainer . isPolymorphObject ( ) ) { const pathParts = containerDesc . nestedPath . split ( '.' ) ; propPtr = ctx . currentPointer . parent . createChildPointer ( ` ${ pathParts [ pathParts . length - 2 ] } ${ propName } ` ) ; } else { propPtr = ctx . currentPointer . parent . createChildPointer ( propName ) ; } if ( ctx . hasErrorsFor ( propPtr ) ) return whenErrors ; const container = ctx . containersChain [ ctx . containersChain . length - 1 ] ; const propValue = container [ propName ] ; if ( testValue !== undefined ) { if ( ( ( testValue instanceof RegExp ) && testValue . test ( propValue ) ) || ( propValue === testValue ) ) return true ; } else { if ( ! isEmpty ( propPtr , propDesc , propValue ) ) return true ; } return false ; }
Tell if the specified context container has specified property and it
optionally matches the specified test value.

@private
@param {module:x2node-validators~ValidationContext} ctx Current validation
context.
@param {string} propName Sibling property name.
@param {(*|RegExp)} [testValue] Test value.
@param {boolean} whenErrors What to return when <code>propName</code> has
validation errors.
@returns {boolean} <code>true</code> if has matching sibling.
Tell if the specified context container has specified property and it optionally matches the specified test value .