Socket
Socket
Sign inDemoInstall

@segment/ajv-human-errors

Package Overview
Dependencies
Maintainers
236
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@segment/ajv-human-errors - npm Package Compare versions

Comparing version 2.0.3-alpha.10 to 2.1.0

4

package.json
{
"name": "@segment/ajv-human-errors",
"version": "2.0.3-alpha.10",
"version": "2.1.0",
"description": "Human-readable error messages for Ajv (Another JSON Schema Validator).",

@@ -34,3 +34,3 @@ "repository": {

},
"gitHead": "398cfff04ed43bc1824303e0d013e2fc86b04f3b"
"gitHead": "07423c6badf7bc7442e55796a643596aa89aad0f"
}

@@ -39,16 +39,16 @@ # @segment/ajv-human-errors

```ts
import Ajv from 'ajv';
import { AggregateAjvError } from '@segment/ajv-human-errors';
import Ajv from 'ajv'
import { AggregateAjvError } from '@segment/ajv-human-errors'
const ajv = new Ajv({
allErrors: true,
verbose: true,
});
verbose: true
})
ajv.validate({ title: 'Bag of Bytes', type: 'string' }, 1234);
ajv.validate({ title: 'Bag of Bytes', type: 'string' }, 1234)
const errors = new AggregateAjvError(ajv.errors);
console.log(errors.message);
const errors = new AggregateAjvError(ajv.errors)
console.log(errors.message)
// 'Bag of Bytes should be a string but it was a number.'
console.log(errors.map(({ message }) => message));
console.log(errors.map(({ message }) => message))
// ['Bag of Bytes should be a string but it was a number.']

@@ -76,13 +76,13 @@ ```

```ts
import { AggregateAjvError } from '@segment/ajv-human-errors';
import { AggregateAjvError } from '@segment/ajv-human-errors'
const errors = new AggregateAjvError(ajv.errors);
const errors = new AggregateAjvError(ajv.errors)
const messages = errors.map(({ message }) => message);
const messages = errors.map(({ message }) => message)
// or
const messages = [];
const messages = []
for (const error of errors) {
messages.push(error.message);
messages.push(error.message)
}

@@ -106,7 +106,7 @@ ```

```ts
const { AggregateAjvError } = require('@segment/ajv-human-errors');
const { AggregateAjvError } = require('@segment/ajv-human-errors')
const errors = new AggregateAjvError(ajv.errors);
const errors = new AggregateAjvError(ajv.errors)
console.log(errors[0].toJSON());
console.log(errors[0].toJSON())
```

@@ -156,4 +156,4 @@

```ts
const errors = new AggregateAjvError(ajv.errors, { includeOriginalError: true });
errors.forEach(({ original }) => console.log(original));
const errors = new AggregateAjvError(ajv.errors, { includeOriginalError: true })
errors.forEach(({ original }) => console.log(original))
```

@@ -177,4 +177,4 @@

```ts
const errors = new AggregateAjvError(ajv.errors, { includeOriginalError: true });
errors.forEach(({ data }) => console.log(data));
const errors = new AggregateAjvError(ajv.errors, { includeOriginalError: true })
errors.forEach(({ data }) => console.log(data))
```

@@ -210,3 +210,3 @@

Copyright (c) 2021 Segment
Copyright (c) 2022 Segment

@@ -213,0 +213,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

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