How to use the ramda-extension.ltThanLength function in ramda-extension

To help you get started, we’ve selected a few ramda-extension examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lundegaard / validarium / packages / predicates / src / isValidIban.js View on Github external
take9chars
);
const computeReducedIban = converge(concat, [moduloOfFirst9Chars, drop9charsFromIban]);

const moveFirstFourCharsToEnd = compose(
	listToString,
	reverse,
	splitAt(4)
);

// on wikipedia they are using hardcoded values, but the value of number can be computed with ascii code - 55
const expandTextCharToNumber = o(listToString, map(when(isNotNumeric, decodeChar)));

// javascript is not capable to compute module on whole number
// https://en.wikipedia.org/wiki/International_Bank_Account_Number#Modulo_operation_on_IBAN
const iso7064Mod97 = ifElse(ltThanLength(2), o(c => iso7064Mod97(c), computeReducedIban), modulo97);

// based on https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN
/**
@alias module:predicates.isValidIban
*/
export default pipe(
	removeWhiteSpaces,
	moveFirstFourCharsToEnd,
	expandTextCharToNumber,
	iso7064Mod97,
	equals(1)
);