Open arnaumanyosa opened 3 weeks ago
@arnaumanyosa It's hard to say why you are seeing errors in one environment but not in another because we know nothing about your application. It's probably because you don't have a content security policy in dev mode, but you do in production.
If your CSP allows unsafe-eval
then you can just pass the schema with the standard ajv8 validator to the Form component. The motivation for the precompiled validators feature is to move compile schemas compilation to the server where the CSP does not apply. This uses node APIs, so there is no way to precompile a validator in the browser.
Prerequisites
What theme are you using?
mui
What is your question?
I have multiple schemas that I get from a REST API endpoint and I use to generate different forms. I do nothing with validators, just passing the one imported directly
This works perfectly on my local. But on production environment I get a very long error message on my browser console that starts like:
Error compiling schema, function code: const schema0 = scope.schema[0];return function validate0(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;if(data && typeof data == "object" && !Array.isArray(data)) ...
1- Why I don't have this error on my local? 2- I read the documentation and discussions like this one, seems like I have to build a custom validator for each of my schemas. Is that correct? 3- Seems like this custom validators should be build on the server. Can I build them on the browser? How?