New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

io-ts-reporters

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ts-reporters - npm Package Compare versions

Comparing version 2.0.0-rc1 to 2.0.0

2

package.json
{
"name": "io-ts-reporters",
"version": "2.0.0-rc1",
"version": "2.0.0",
"description": "Formatting of io-ts validation errors",

@@ -5,0 +5,0 @@ "main": "./target/src/index.js",

@@ -6,4 +6,4 @@ # io-ts-reporters

Currently this package only includes one reporter. The output is an array of strings in the format
of:
Currently this package only includes one reporter. The output is an array of
strings in the format of:

@@ -48,4 +48,4 @@ ```

To only format the validation errors in case the validation failed (ie. `mapLeft`) use
`formatValidationErrors` instead.
To only format the validation errors in case the validation failed (ie.
`mapLeft`) use `formatValidationErrors` instead.

@@ -52,0 +52,0 @@ ```ts

@@ -32,3 +32,4 @@ /**

const jsToString = (value: t.mixed) => (value === undefined ? 'undefined' : JSON.stringify(value))
const jsToString = (value: t.mixed) =>
value === undefined ? 'undefined' : JSON.stringify(value)

@@ -92,3 +93,5 @@ const keyPath = (ctx: t.Context) =>

'Expecting one of:\n',
expectedTypes.map((type) => ` ${truncateType(type, options)}`).join('\n'),
expectedTypes
.map((type) => ` ${truncateType(type, options)}`)
.join('\n'),
path === '' ? '\n' : `\nat ${path} `,

@@ -130,3 +133,5 @@ `but instead got: ${jsToString(value)}`,

return expected.length > 0 ? O.some(errorMessageUnion(expected, path, value, options)) : O.none
return expected.length > 0
? O.some(errorMessageUnion(expected, path, value, options))
: O.none
}

@@ -142,3 +147,5 @@

getErrorFromCtx,
O.map((errorContext) => errorMessageSimple(errorContext.type.name, path, error, options)),
O.map((errorContext) =>
errorMessageSimple(errorContext.type.name, path, error, options),
),
)

@@ -165,4 +172,6 @@

*/
export const formatValidationError = (error: t.ValidationError, options?: ReporterOptions) =>
formatValidationCommonError(keyPath(error.context), error, options)
export const formatValidationError = (
error: t.ValidationError,
options?: ReporterOptions,
) => formatValidationCommonError(keyPath(error.context), error, options)

@@ -187,3 +196,6 @@ /**

*/
export const formatValidationErrors = (errors: t.Errors, options?: ReporterOptions) =>
export const formatValidationErrors = (
errors: t.Errors,
options?: ReporterOptions,
) =>
pipe(

@@ -213,3 +225,6 @@ errors,

*/
export const reporter = <T>(validation: t.Validation<T>, options?: ReporterOptions) =>
export const reporter = <T>(
validation: t.Validation<T>,
options?: ReporterOptions,
) =>
pipe(

@@ -225,3 +240,6 @@ validation,

interface PrettyReporter extends Reporter<string[]> {
report: <T>(validation: t.Validation<T>, options?: ReporterOptions) => string[]
report: <T>(
validation: t.Validation<T>,
options?: ReporterOptions,
) => string[]
}

@@ -228,0 +246,0 @@

@@ -34,3 +34,5 @@ "use strict";

};
var jsToString = function (value) { return (value === undefined ? 'undefined' : JSON.stringify(value)); };
var jsToString = function (value) {
return value === undefined ? 'undefined' : JSON.stringify(value);
};
var keyPath = function (ctx) {

@@ -81,3 +83,5 @@ // The context entry with an empty key is the original

'Expecting one of:\n',
expectedTypes.map(function (type) { return " " + truncateType(type, options); }).join('\n'),
expectedTypes
.map(function (type) { return " " + truncateType(type, options); })
.join('\n'),
path === '' ? '\n' : "\nat " + path + " ",

@@ -101,6 +105,10 @@ "but instead got: " + jsToString(value),

});
return expected.length > 0 ? O.some(errorMessageUnion(expected, path, value, options)) : O.none;
return expected.length > 0
? O.some(errorMessageUnion(expected, path, value, options))
: O.none;
};
var formatValidationCommonError = function (path, error, options) {
return pipeable_1.pipe(error, getErrorFromCtx, O.map(function (errorContext) { return errorMessageSimple(errorContext.type.name, path, error, options); }));
return pipeable_1.pipe(error, getErrorFromCtx, O.map(function (errorContext) {
return errorMessageSimple(errorContext.type.name, path, error, options);
}));
};

@@ -121,5 +129,3 @@ var groupByKey = NEA.groupBy(function (error) {

*/
var formatValidationError = function (error, options) {
return formatValidationCommonError(keyPath(error.context), error, options);
};
var formatValidationError = function (error, options) { return formatValidationCommonError(keyPath(error.context), error, options); };
exports.formatValidationError = formatValidationError;

@@ -126,0 +132,0 @@ /**

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc