backend validation wip

This commit is contained in:
newtbot
2024-01-02 02:53:44 +08:00
parent a058b1ba70
commit 6342d5a4cb
13 changed files with 410 additions and 211 deletions

View File

@ -11,21 +11,60 @@ const locationModel = sequelize.define(
allowNull: true,
primaryKey: true,
autoIncrement: true,
validator: {
isNumeric: true,
},
},
name: {
type: DataTypes.STRING,
allowNull: false,
length: 10,
validator: {
notEmpty: { msg: "Name cannot be empty" },
len: [1, 20],
/*
//will not validate this and fail it
"hello world" (contains a space)
"hello@123" (contains a symbol)
"" (empty string)
*/
is: ["^[a-z0-9]+$", "i"]
},
},
added_by: {
type: DataTypes.STRING,
allowNull: false,
length: 10,
validator: {
notEmpty: { msg: "Added by cannot be empty" },
len: [1, 20],
/*
//will not validate this and fail it
"hello world" (contains a space)
"hello@123" (contains a symbol)
"" (empty string)
*/
is: ["^[a-z0-9]+$", "i"]
},
},
description: {
type: DataTypes.STRING,
allowNull: true,
length: 100,
validator: {
notEmpty: { msg: "Description cannot be empty" },
len: [1, 100],
/*
//will not validate this and fail it
"hello world" (contains a space)
"hello@123" (contains a symbol)
"" (empty string)
*/
is: ["^[a-z0-9]+$", "i"]
},
},
createdAt: {
type: DataTypes.DATE,