Skip to content

mattiamalonni/sequelize-joi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sequelize Joi

Allows specifying Joi validation schema for model attributes in Sequelize.

Installation

npm install sequelize-joi

Usage

const { Sequelize, DataTypes } = require("sequelize");
const { sequelizeJoi, Joi } = require("sequelize-joi");

const database = new Sequelize({
  ...sequelizeConnectionOptions,
});

sequelizeJoi(database);

const User = database.define("User", {
  username: {
    type: DataTypes.STRING,
    schema: Joi.string().trim().alphanum().min(6).max(30),
  },
  email: {
    type: DataTypes.STRING,
    schema: Joi.string().trim().required().email(),
  },
  password: {
    type: DataTypes.STRING,
    schema: Joi.string().trim().required().min(8),
  },
});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published