I have encountered a situation where I want to ensure a supplied JSON schema will be compatible with this library, specifically I want to be sure that it will be able to run against schema validation without throwing an error. I can import ajv on my own to run validate, but my preference would be to run against the same validate logic that is used by the form component. The only way I could see to do that now is to instantiate a form component, access it via a ref, and trigger its internal validate property. A more straightforward approach for my case would be to import the util function it uses and run it myself.
1.0.5
I don't think we do anything specific to validate the schema itself. We rely on ajv's schema validation to do it. I don't think importing ajv directly is a bad choice. Otherwise, maybe we should expose our ajv instance?
While I suspect there might still be value in exposing the whole validate method exposing the ajv instance alone may be sufficient. This is especially true since the ajv instance has custom formats added to it after instantiation...
ajv.addFormat(
"data-url",
/^data:([a-z]+\/[a-z0-9-+.]+)?;name=(.*);base64,(.*)$/
);
ajv.addFormat(
"color",
/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/
);
Has any more happened on this? I think exposing the ajv instance and/or allowing an external instance of ajv to be passed in on RJSF init would be very useful, specifically for the purpose of adding formats or keywords to the ajv validator.
Most helpful comment
While I suspect there might still be value in exposing the whole validate method exposing the ajv instance alone may be sufficient. This is especially true since the ajv instance has custom formats added to it after instantiation...