ajv-validator / ajv-validator/ajv-errors

Unable to use package in browser

Đang mở
#158 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
289
Fork
21
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The following simple example works in NodeJS

```
import Ajv from 'ajv';
import ajvErrors from 'ajv-errors';

const ajv = new Ajv({
allErrors: true,
});

ajvErrors(ajv);

const schema = {
type: 'object',
properties: {
myFieldA: {
type: 'integer',
},
myFieldB: {
type: 'string',
},
},
errorMessage: {
properties: {
myFieldA: 'My Error Message 1',
myFieldB: 'My Error Message 2',
},
}
}

const submittedData = {
myFieldA: 'Hello World',
myFieldB: 1,
};

ajv.validate(schema, submittedData)

console.log(ajv.errors);
```

But the following simple example which is the same as the above example except it imports the package from a CDN, does not work

```

import Ajv from 'https://esm.sh/ajv@8.17.1';
import ajvErrors from 'https://esm.sh/ajv-errors@3.0.0';

const ajv = new Ajv({
allErrors: true,
});

ajvErrors(ajv);

const schema = {
type: 'object',
properties: {
myFieldA: {
type: 'integer',
},
myFieldB: {
type: 'string',
},
},
errorMessage: {
properties: {
myFieldA: 'My Error Message 1',
myFieldB: 'My Error Message 2',
},
}
}

const submittedData = {
myFieldA: 'Hello World',
myFieldB: 1,
};

ajv.validate(schema, submittedData);

console.log(ajv.errors);

```

I did the same thing to get `ajv-keywords`, `ajv-formats` packages to work in the browser by using esm.sh CDN. However I am unable to get `ajv-errors` to work.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.