Custom AJV validation

Hi All,

I know this is probably more a question for AJV but I didn’t get any response on their forum. I’m trying to add a user defined ajv keyword definition that adds support for enumerations that are dynamically taken from other parts of the data and not statically defined upfront, i’m calling this dataEnum. I’ve managed to create a custom renderer that populates the list of enumerations at runtime depending on what data I have in the rest of my JSON.

I’m looking to add validation to check that the provided value is in the set of possible enumerations. I’ve tried specifying a validate function on my keywordDef and this gives me all the functionality I need however the performance is not quite good enough (i’m using AJV to validate a JSON file that I configure through a form on a webapp using the json-forms framework). I’m now trying to use the code function as part of the keywordDef however in this function I cannot find a way to access the path to the piece of data it’s currently validating. In the validate function that was accessible using dataCxt.instancePath but I can’t find anything similar on the KeywordCxt. i’m relatively new to AJV so apologies if any of the above doesn’t quite make sense or if there is an obvious easier approach.

Any suggestions would be greatly appreciated.

Best regards,
James

1 Like