How to use the rambda.join function in rambda

To help you get started, we’ve selected a few rambda 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 terascope / teraslice / packages / elasticsearch-store / src / utils / errors.ts View on Github external
import * as R from 'rambda';
import * as ts from '@terascope/utils';
import ajv from 'ajv';

export const getErrorMessages: (errors: ErrorLike[]) => string = R.pipe(
    R.map(getErrorMessage),
    R.join(', ')
);

export function throwValidationError(errors: ErrorLike[] | null | undefined): string | null {
    if (errors == null) return null;
    if (!errors.length) return null;

    const errorMsg = getErrorMessages(errors);

    const error = new ts.TSError(errorMsg, {
        statusCode: 400,
    });

    Error.captureStackTrace(error, throwValidationError);
    throw error;
}