How to use the z-schema.getRegisteredFormats function in z-schema

To help you get started, we’ve selected a few z-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github isa-group / oas-tools / src / middleware / oas-validator.js View on Github external
keepGoing = false;
        } else { // In case the parameter is indeed present, check type. In the case of array, check also type of its items!
          try { // eslint-disable-line
            if (schema.type !== 'string') { // eslint-disable-line
              value = JSON.parse(req[location][name]);
            } else {
              value = String(req[location][name]);
            }
          } catch (err) {
            value = String(req[location][name]);
          }
          err = validator.validate(value, schema);
          if (err == false) {  // eslint-disable-line
            keepGoing = false;
            if (err.code == "UNKNOWN_FORMAT") { // eslint-disable-line
              var registeredFormats = ZSchema.getRegisteredFormats();
              logger.error("UNKNOWN_FORMAT error - Registered Formats: ");
              logger.error(registeredFormats);
            }
            newErr = {
              message: "Wrong parameter " + name + " in " + location + ". ",
              error: validator.getLastErrors()
            };
            msg.push(newErr);
          } else {
            logger.info("Valid parameter on request");
          }
        }
      }
    }
  }
  if (keepGoing == false && config.strict == true) {
github apigee-127 / swagger-tools / lib / helpers.js View on Github external
traverse(json).forEach(function () {
    var name = this.key;
    var format = this.node;

    if (name === 'format' && _.indexOf(ZSchema.getRegisteredFormats(), format) === -1) {
      ZSchema.registerFormat(format, function () {
        return true;
      });
    }
  });
};