ajv
ajv copied to clipboard
Incomplete documentation for validateSchema method in _KeywordDef?
I want to implement a keyword called order for object schema type. However, I can't access the object schema in validateSchema function.
What version of Ajv are you using? Does the issue happen if you use the latest version? 8.1
Ajv options object
JSON Schema
{
type: 'object',
properties: {
name: {
type: 'string'
},
age: {
type: 'integer'
}
},
order: ['name', 'age'],
required: ['name', 'age']
}
Sample data
{ name: 'test', age: 10 }
Your code
ajv.addKeyword({
keyword: 'order',
type: 'object',
schemaType: 'array',
});
Validation result, data AFTER validation, error messages
What results did you expect?
I wanted to be able to use validateSchema to look at my object's properties to validate my keyword schema. Specifically to verify that the strings inside order keyword to be the properties in the object.
Are you going to resolve the issue? No, I can't
By the way, I think you should enable discussions on this project or some way to asking a questions. Or there can be an Issue category where I can raise a problem with documentation. Because this is not strictly a bug but at the same time I don't know if it's a bug in the docs.
I will create an issue template for docs questions
I don’t hunk I understand the question, sorry. Please look at the implementations of keywords in ajv-keywords package - there may be some helpful examples
validateSchema method you can see in the type is the result of metaSchema compilation - normally you won’t use it, so it’s not documented.