src/line-header.js
function getStrictCheck(expectedHeader, caseSensitive, severity) {

	return function (content) {
		let actualHeader;
		if (caseSensitive) {
			actualHeader = content;
		} else {
			actualHeader = arrayToUpperCase(content);
			expectedHeader = arrayToUpperCase(expectedHeader);
		}

		if (expectedHeader.length !== actualHeader.length) {
			// If the length is different, it could not be the same
			return {
				errorCode: 'CHECK_HEADER_NO_STRICT_MATCH',
				severity: severity,
				message: 'The expected header [' + expectedHeader +
					'] has a different column count to the actual header [' + actualHeader +
					']'
			};
		} else {
			// no we need to compare field by field because the expected array could be an array of arrays
			// The expected header may contain alternative names for one column.
			for (let i = 0; i < expectedHeader.length; i++) {
				let match = false;
				const actualVal = actualHeader[i];
				let expectedVal = expectedHeader[i];
				if (Array.isArray(expectedVal)) {
					for (let j = 0; j < expectedVal.length; j++) {
						if (actualVal === expectedVal[j]) {
							match = true;
						}
					}
				} else {
					if (actualVal === expectedVal) {
						match = true;
					}
				}
				if (!match) {
					return {
						errorCode: 'CHECK_HEADER_NO_STRICT_MATCH',
						severity: severity,
						message: 'The expected header [' + expectedHeader +
							'] does not match the actual header [' +
							actualHeader +
							']'
					};
				}
			}
		}
	};
}
function getStrictCheck(expectedHeader, caseSensitive, severity) {

	return function (content) {
		let actualHeader;
		if (caseSensitive) {
			actualHeader = content;
		} else {
			actualHeader = arrayToUpperCase(content);
			expectedHeader = arrayToUpperCase(expectedHeader);
		}

		if (expectedHeader.length !== actualHeader.length) {
			// If the length is different, it could not be the same
			return {
				errorCode: 'CHECK_HEADER_NO_STRICT_MATCH',
				severity: severity,
				message: 'The expected header [' + expectedHeader +
					'] has a different column count to the actual header [' + actualHeader +
					']'
			};
		} else {
			// no we need to compare field by field because the expected array could be an array of arrays
			// The expected header may contain alternative names for one column.
			for (let i = 0; i < expectedHeader.length; i++) {
				let match = false;
				const actualVal = actualHeader[i];
				let expectedVal = expectedHeader[i];
				if (Array.isArray(expectedVal)) {
					for (let j = 0; j < expectedVal.length; j++) {
						if (actualVal === expectedVal[j]) {
							match = true;
						}
					}
				} else {
					if (actualVal === expectedVal) {
						match = true;
					}
				}
				if (!match) {
					return {
						errorCode: 'CHECK_HEADER_NO_STRICT_MATCH',
						severity: severity,
						message: 'The expected header [' + expectedHeader +
							'] does not match the actual header [' +
							actualHeader +
							']'
					};
				}
			}
		}
	};
}
function getStrictCheck ( expectedHeader , caseSensitive , severity ) { return function ( content ) { let actualHeader ; if ( caseSensitive ) { actualHeader = content ; } else { actualHeader = arrayToUpperCase ( content ) ; expectedHeader = arrayToUpperCase ( expectedHeader ) ; } if ( expectedHeader . length !== actualHeader . length ) { // If the length is different, it could not be the same return { errorCode : 'CHECK_HEADER_NO_STRICT_MATCH' , severity : severity , message : 'The expected header [' + expectedHeader + '] has a different column count to the actual header [' + actualHeader + ']' } ; } else { // no we need to compare field by field because the expected array could be an array of arrays // The expected header may contain alternative names for one column. for ( let i = 0 ; i < expectedHeader . length ; i ++ ) { let match = false ; const actualVal = actualHeader [ i ] ; let expectedVal = expectedHeader [ i ] ; if ( Array . isArray ( expectedVal ) ) { for ( let j = 0 ; j < expectedVal . length ; j ++ ) { if ( actualVal === expectedVal [ j ] ) { match = true ; } } } else { if ( actualVal === expectedVal ) { match = true ; } } if ( ! match ) { return { errorCode : 'CHECK_HEADER_NO_STRICT_MATCH' , severity : severity , message : 'The expected header [' + expectedHeader + '] does not match the actual header [' + actualHeader + ']' } ; } } } } ; }
returns the Strict header check
@param expectedHeader The expected header
returns the Strict header check