Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* Recursively translates messages in validation result.
*/
const translate = formatMessage =>
cond([
[isIntlMessageWithArgs, ({ message, messageValues }) => formatMessage(message, messageValues)],
[notNilObject, map(unlessIsNil(x => translate(formatMessage)(x)))],
[T, identity],
]);
const existFormatMessage = o(isFunction, path(['intl', 'formatMessage']));
/**
* For merging validation results.
* We don't want to null results replacing those already filled.
*/
const mergeResults = mergeDeepAllWith(
cond([
[isNilOrAllIsNil, nthArg(1)],
[flip(isNilOrAllIsNil), headArg],
[(a, b) => isObject(a) && isObject(b), mergeDeepLeft],
[T, headArg],
])
);
/**
* Applies `fns` with `values` and `props`.
* Results of `fns` are translated with `react-intl`;
* We assume that `props` contains `intl` object from `react-intl` (usually obtained by `injectIntl`).
*
* @param {...Function} fns Validation functions.
* @param {Object} props
* @param {any} values