Original
export const isTimeStrValid = str => {
return str.length >= 4 && moment(str, ['H:mm', 'HH:mm'], true).isValid();
};
Ramda
export const isTimeStrValid = R.allPass([
R.pipe(R.length, R.gte(R.__, 4)),
R.pipe(
s => moment(s, ['H:mm', 'HH:mm'], true),
R.invoker(0, 'isValid'),
),
]);
The Ramda/functional programming version feels verbose but I can't quite figure out how to make it more elegant. As it stands, it appears that the original/imperative version is easier to read/understand. Does my Ramda version follow conventions/best practices?