4

Example:

/**
*
* @param {any} data - Object to be validated
* @params {Object} schema - JSON schema
* @params {Object} schema.properties - JSON schema properties
* ** @params {string} schema.properties[any].type - field property type ???**
*/
function validate(data, schema) {
}

similiar to JsDoc: How do I document that an object can have arbritrary (unknown) properties but with a particular type?

JSDoc Object of templated objects

1 Answers1

3

For this particular case:

/**
 * @param {Object} data
 * @param {{properties: Object.<string, {type: string}>}} schema
 */
function validate(data, schema) {
    schema.properties['test'].type = 'test';
}

Alternatively, if you don't mind not being compatible with the Closure Compiler (it still works in WebStorm):

/**
 * @typedef {Object} Property
 * @property {string} type
 */

/**
 * @typedef {Object} Schema
 * @property {Object.<string, Property>} properties
 */

/**
 * @param {Object} data
 * @param {Schema} schema
 */
function validate(data, schema) {
    schema.properties['test'].type = 'test';
}

See:

http://usejsdoc.org/tags-type.html#jsdoc-types