ajv-validator / ajv-validator/ajv

Allow it to work on edge (e.g. cloudflare workers)

オープン
#2,491 コメント 8 件 リアクション 3 件 担当者 0 名 GitHub で見る
compatibility
主要言語
TypeScript
スター
14.8k
フォーク
1k
PR マージ指標
30日以内にマージされた PR はありません

説明

There is already an issue for this , https://github.com/ajv-validator/ajv/issues/2318, but it is closed. Suggestion there is not working when ajv is XX-layers down like eg: [async-parser](https://github.com/asyncapi/parser-js) -> [@stoplight/spectral](https://github.com/stoplightio/spectral)->ajv and dynamic schema is validated, there is not visible to generate and pass validation function all the way down.

**The version of Ajv you are using**
latest

**The environment you have the problem with**
cloudflare worker

**Your code (please make it as small as possible to reproduce the issue)**
standard example from async-parser [Example](https://github.com/asyncapi/parser-js?tab=readme-ov-file#example-with-parsing)

Works in every browser and node env, except of cloudflare worker.

**Results and error messages in your platform**
```
Code generation from strings disallowed for this context

at new Function ()
at m.f
```

If there is no way to drop `new Function` usage in general, maybe it could be made conditional? let's say if `option.workerSafe` is passed as true, do something worker safe instead of new function?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。