@gridql/payload-validator
TypeScript icon, indicating that this package has built-in type declarations

3.8.4 • Public • Published

Payload Validator

All this does is wrap json-schema. We just needed the same function in multiple modules.

Usage

    const {valid} = require("@gridql/payload-validator");

    const schema = {
      type: "object",
      properties: {
        object_id: {
          type: "string",
          format: "uuid",
        },
        firstName: {
          type: "string",
          faker: "name.firstName",
        },
        lastName: {
          type: "string",
          faker: "name.lastName",
        }
      },
      required: ["firstName", "lastName",],
    };

    const valid = valid(schema);

    if(valid(payload)){
        ...
    }

See tests for more complex examples.

Readme

Keywords

none

Package Sidebar

Install

npm i @gridql/payload-validator

Weekly Downloads

0

Version

3.8.4

License

MIT

Unpacked Size

6.01 kB

Total Files

10

Last publish

Collaborators

  • tsmarsh