How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • const ajv = new Ajv({ $data: true });
    
    const schema = {
      properties: {
        smaller: {
          type: "number",
          maximum: { $data: "1/larger" },
        },
        larger: { type: "number" },
      },
    };
    
    const validData = {
      smaller: 5,
      larger: 7,
    };
    
    ajv.validate(schema, validData); // true
    
    Docs
    0
  • const Ajv = require("ajv").default;
    const schema_user = require("./schema_user.json");
    const ajv = new Ajv();
    const validate_user = ajv.compile(schema_user);
    
    // this is just some abstract API framework
    app.post("/user", async (cxt) => {
      if (validate_user(cxt.body)) {
        // create user
      } else {
        // report error
        cxt.status(400);
      }
    });
    
    Docs
    0
  • const { default: Ajv, _ } = require("ajv");
    const ajv = new Ajv({
      code: { formats: _`require("./my_formats")` },
    });
    
    Docs
    0
  • const Ajv = require("ajv").default;
    const ajv = new Ajv({ allErrors: true });
    // Ajv option allErrors is required
    require("ajv-errors")(ajv /*, {singleError: true} */);
    
    Docs
    0
  • const ajv = new Ajv({ schemas: [schema, defsSchema] });
    const validate = ajv.getSchema(
      "http://example.com/schemas/schema.json"
    );
    
    Docs
    0
  • const validate = new Ajv()
      .addSchema(schema)
      .addFormat(name, regex)
      .getSchema(uri);
    
    Docs
    -1
  • import Ajv from "ajv";
    import * as schema_user from "./schema_user.json";
    import * as schema_document from "./schema_document.json";
    export const ajv = new Ajv();
    ajv.addSchema(schema_user, "user");
    ajv.addSchema(schema_document, "document");
    
    Docs
    1
  • const ajv = new Ajv();
    const validate = ajv.addSchema(defsSchema).compile(schema);
    
    Docs
    1
  • parser
      .dereference(
        path.resolve("src/backend/schema/index.json")
      )
      .then((schema) => {
        ajv.addSchema(schema);
        return schema;
      });
    
    /jc21/juxtapose mit
    0
  • const validate = new Ajv()
      .addSchema(schema)
      .addFormat(name, regex)
      .getSchema(uri);
    
    Docs
    -1
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples