How to use the jest-validate.ValidationError function in jest-validate

To help you get started, we’ve selected a few jest-validate 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 facebook / jest / packages / jest-config / src / ReporterValidationErrors.ts View on Github external
) {
  const errorMessage =
    `  Unexpected value for ${valueName} ` +
    `at index ${valueIndex} of reporter at index ${reporterIndex}\n` +
    '  Expected:\n' +
    `    ${chalk.bold.red(expectedType)}\n` +
    '  Got:\n' +
    `    ${chalk.bold.green(getType(value))}\n` +
    `  Reporter configuration:\n` +
    `    ${chalk.bold.green(
      JSON.stringify(arrayReporter, null, 2)
        .split('\n')
        .join('\n    '),
    )}`;

  return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE);
}
github jest-community / jest-watch-toggle-config / src / index.js View on Github external
function errorOut(message) {
  const comment = `${chalk.bold.red(
    'Configuration documentation'
  )}: ${chalk.underline(
    'https://github.com/jest-community/jest-watch-toggle-config#readme'
  )}
  `.trim()
  throw new ValidationError('Watch Toggle Config Error', message, comment)
}
github facebook / jest / packages / jest-config / src / ReporterValidationErrors.ts View on Github external
export function createReporterError(
  reporterIndex: number,
  reporterValue: Array | string,
) {
  const errorMessage =
    `  Reporter at index ${reporterIndex} must be of type:\n` +
    `    ${chalk.bold.green(validReporterTypes.join(' or '))}\n` +
    `  but instead received:\n` +
    `    ${chalk.bold.red(getType(reporterValue))}`;

  return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE);
}
github facebook / jest / packages / jest-config / src / utils.ts View on Github external
const createValidationError = (message: string) =>
  new ValidationError(`${BULLET}Validation Error`, message, DOCUMENTATION_NOTE);
github facebook / jest / packages / jest-config / src / normalize.ts View on Github external
const createConfigError = (message: string) =>
  new ValidationError(ERROR, message, DOCUMENTATION_NOTE);

jest-validate

Generic configuration validation tool that helps you with warnings, errors and deprecation messages as well as showing users examples of correct configuration.

MIT
Latest version published 8 months ago

Package Health Score

93 / 100
Full package analysis

Similar packages