How to use the @stoplight/prism-core.ValidationSeverity.ERROR function in @stoplight/prism-core

To help you get started, we’ve selected a few @stoplight/prism-core 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 stoplightio / prism / packages / http / src / validator / helpers / validateAgainstSchema.ts View on Github external
export function validateAgainstSchema(value: any, schema: ISchema, prefix: string): IValidation[] {
  const validate = ajv.compile(schema);

  if (!validate(value)) {
    return convertAjvErrors(validate.errors, ValidationSeverity.ERROR).map(error =>
      Object.assign({}, error, { path: [prefix, ...error.path] })
    );
  }

  return [];
}