@segment/ajv-human-errors
Advanced tools
Comparing version 2.0.3-alpha.10 to 2.1.0
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
129122
1