# Javacript error - Error compiling schema (AJV related)

**URL:** <https://jsonforms.discourse.group/t/javacript-error-error-compiling-schema-ajv-related/978>\
**Category:** General\
**Created:** [August 26, 2022, 11:50am UTC](https://jsonforms.discourse.group/t/javacript-error-error-compiling-schema-ajv-related/978 "2022-08-26T11:50:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cornelos](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/cornelos/32/274_2.png) [@cornelos](https://jsonforms.discourse.group/u/cornelos)\
**Post date:** [August 26, 2022, 11:50am UTC](https://jsonforms.discourse.group/t/javacript-error-error-compiling-schema-ajv-related/978/1 "2022-08-26T11:50:32Z")

</div>

Hi all!

I am experiencing a strange problem.  
My json form (in Angular) is rendering without problems when running from Visual Code with `ng serve`.  
But when running the application from Azure I get this error in the console while rendering the form:

`Error compiling schema, function code: const schema2 = scope.schema[2];const schema1 = scope.schema[1];return function validate3(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;if(!((typeof data == "number") && (!(data % 1) && !isNaN(data)))){const err0 = {instancePath,schemaPath:"#/definitions/nonNegativeInteger/type",keyword:"type",params:{type: "integer"},message:"must be integer",schema:schema1.type,parentSchema:schema1,data};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(typeof data == "number"){if(data < 0 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/definitions/nonNegativeInteger/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0",schema:0,parentSchema:schema1,data};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}validate3.errors = vErrors;return errors === 0;}`

Did any of you see this error before? What could it be?

new info: It seems to be related to AJV

---

<div class="post-metadata">

**Author:** ![cornelos](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/cornelos/32/274_2.png) [@cornelos](https://jsonforms.discourse.group/u/cornelos)\
**Post date:** [August 26, 2022, 2:36pm UTC](https://jsonforms.discourse.group/t/javacript-error-error-compiling-schema-ajv-related/978/2 "2022-08-26T14:36:09Z")

</div>

Problem was caused by the Content-Security-Policy header!

The underlying exception was: `EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'"`

The problem was solved by adding ‘unsafe-eval’ to the ‘script-src’ part of my Content-Security-Policy settings.

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [August 31, 2022, 4:05pm UTC](https://jsonforms.discourse.group/t/javacript-error-error-compiling-schema-ajv-related/978/3 "2022-08-31T16:05:16Z")

</div>

Hi @cornelos,

AJV does code-gen internally and therefore requires the `unsafe-eval` option. If you’re not able to use `unsafe-eval` then there is a workaround if you know all schemas beforehand. See [here](https://github.com/eclipsesource/jsonforms/issues/1498) for more information.
