0

As you know jsdoc and similar javadoc allows describing and verification of function signatures. It allows describe possible type, enum, custom type and even possible list of values. https://apidocjs.com#param-api-param , How to document a string type in jsdoc with limited possible values .

But I can not find example for regular comparator less than (&lt; <) or external custom function. And even more: I need not only for decimal number, but e.g. for rounded float/double too.

P.S.: You could tell me, that jsdoc is only for documentation generation and human reading and human can not read such functions, but it is wrong. There are already many solutions for auto checking by jsdoc format (e.g. like TypeScript and ESLint, but they can not check runtime wholeness and value contracts for input-output).

Simplified example of requested in runtime checking:

/**
 * @param {number} height
 * @param {string} firstname
 * @param {string} nickname
 *
 * @pre height > 100 && (firstname || nickname.length >= 4)
 */
function setState (height, firstname, nickname) {
  ...
}
user1742529
  • 260
  • 4
  • 16
  • Can you clarify what you mean by using the less than comparator? Do you mean having a type which is set to `< 12.5` or something? – shadowtime2000 Jan 07 '21 at 21:10
  • @shadowtime2000, I mean using external functions or regular conditions, which usually have less than (or great than) comparators. Question (updated) is about similar syntax support in jsdoc, which lately can be parsed. – user1742529 Feb 03 '21 at 06:25

0 Answers0