Skip to content
Discussion options

You must be logged in to vote

It requires additional chai plugin support, will take a look into it.

Probably you could try ajv for now:

// or ESM/TypeScript import
import Ajv from "ajv"
// Node.js require:
const Ajv = require("ajv")

const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}

const schema = {
  type: "object",
  properties: {
    foo: {type: "integer"},
    bar: {type: "string"},
  },
  required: ["foo"],
  additionalProperties: false,
}

const data = {
  foo: 1,
  bar: "abc",
}

const validate = ajv.compile(schema)
const valid = validate(data)
// insomnia.expect

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Ilie-c
Comment options

You must be logged in to vote
2 replies
@ihexxa
Comment options

@ihexxa
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants