comment.js 573 B

1234567891011121314
  1. 'use strict';
  2. module.exports = function generate_comment(it, $keyword, $ruleType) {
  3. var out = ' ';
  4. var $schema = it.schema[$keyword];
  5. var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
  6. var $breakOnError = !it.opts.allErrors;
  7. var $comment = it.util.toQuotedString($schema);
  8. if (it.opts.$comment === true) {
  9. out += ' console.log(' + ($comment) + ');';
  10. } else if (typeof it.opts.$comment == 'function') {
  11. out += ' self._opts.$comment(' + ($comment) + ', ' + (it.util.toQuotedString($errSchemaPath)) + ', validate.root.schema);';
  12. }
  13. return out;
  14. }