Add validation to User sequelize model
This commit is contained in:
parent
3634774ff9
commit
52f603ccc4
|
@ -11,16 +11,27 @@ function getSequelizeModels (sequelize) {
|
||||||
type: Sequelize.STRING,
|
type: Sequelize.STRING,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
unique: true,
|
unique: true,
|
||||||
|
validate: {
|
||||||
|
isEmail: true,
|
||||||
|
len: [5, 150],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
type: Sequelize.STRING,
|
type: Sequelize.STRING,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
unique: true,
|
unique: true,
|
||||||
|
validate: {
|
||||||
|
is: /^[a-z0-9_]+$/i, // Is a set of characters a-z, 0-9, or _, case insensitive
|
||||||
|
len: [2, 32],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
displayName: {
|
displayName: {
|
||||||
type: Sequelize.STRING,
|
type: Sequelize.STRING,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
unique: true,
|
unique: true,
|
||||||
|
validate: {
|
||||||
|
len: [2, 32],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
passwordHash: {
|
passwordHash: {
|
||||||
type: Sequelize.STRING,
|
type: Sequelize.STRING,
|
||||||
|
|
Loading…
Reference in New Issue