1.1.3 • Published 2 years ago

joi-to-md v1.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Usage

import Joi from "joi";
import joiToMd from "joi-to-md";

//Example JOI Schema
const schema = Joi.object({
  username: Joi.string()
    .alphanum()
    .min(3)
    .max(30)
    .required()
    .description("The username, can't get much simpler than that."),
  password: Joi.string()
    .pattern(new RegExp("^[a-zA-Z0-9]{3,30}$"))
    .description("The password for the user's account."),
  birth_year: Joi.number()
    .integer()
    .min(1900)
    .max(2021)
    .required()
    .description("The year the user was born."),
  email: Joi.string()
    .email({
      minDomainSegments: 2,
      tlds: { allow: ["com", "net"] },
    })
    .optional()
    .description("The user's email address"),
  siblings: Joi.array().items(
    Joi.object({
      name: Joi.string().description("The name of the sibling"),
      birth_year: Joi.number()
        .integer()
        .min(1900)
        .max(2021)
        .description("The year the sibling was born"),
    })
  ),
})
  .with("username", "birth_year")
  .xor("password", "access_token")
  .with("password", "repeat_password");

console.log(joiToMd(schema));
1.1.3

2 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago