1.0.4 • Published 10 months ago

@vriddhi-beckn/core-specs v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@vriddhi-beckn/core-specs

Core specifications of Beckn. This package will validate the json input or object in compliance with the core specifications of Beckn.

Installation

npm i @vriddhi-beckn/core-specs

Usage

Input

const schema = require("@vriddhi-beckn/core-specs");

const image = {
  url: "http://example.com/example.png",
  size_type: "xs",
  width: "200px",
  height: "300px",
};

console.log(schema.image.set(image).get());

Output

{
  "url": "http://example.com/example.png",
  "size_type": "xs",
  "width": "200px",
  "height": "300px"
}

Extend

const becknExtend = require("@vriddhi-beckn/core-specs/extend");

const [FooBar, fooBar] = becknExtend("FooBar", (Joi) => {
  return Joi.object({
    message: Joi.string().required(),
  });
});

console.log(fooBar instanceof FooBar); // true
// console.log(fooBar.set({}).get()); // Errors
console.log(fooBar.set({ message: "Hello, World!" }).get()); // Errors

If you want to work with the class itself, use the first item of array provided by the extend function, or you can directly use the object of your class by using the second item of array.

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago