seedroute and vlidate
This commit is contained in:
@ -15,7 +15,7 @@ const api_log_Model = sequelize.define(
|
||||
allowNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
validator: {
|
||||
validate: {
|
||||
isNumeric: true,
|
||||
},
|
||||
},
|
||||
@ -23,7 +23,7 @@ const api_log_Model = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 45,
|
||||
validator: {
|
||||
validate: {
|
||||
isIP: true,
|
||||
},
|
||||
},
|
||||
@ -31,7 +31,7 @@ const api_log_Model = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 20,
|
||||
validator: {
|
||||
validate: {
|
||||
//validate time: new Date().toUTCString(),
|
||||
isValidDateString(value) {
|
||||
if (!isValidDateString(value)) {
|
||||
@ -46,7 +46,7 @@ const api_log_Model = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 10,
|
||||
validator: {
|
||||
validate: {
|
||||
isIn: [["GET", "POST", "PUT", "DELETE"]],
|
||||
},
|
||||
},
|
||||
@ -54,18 +54,12 @@ const api_log_Model = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 45,
|
||||
validator: {
|
||||
//http://localhost/api/test
|
||||
//remember to add domain name to the list
|
||||
isIn: [["localhost"]],
|
||||
//isFqdn: true,
|
||||
},
|
||||
},
|
||||
statusCode: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 10,
|
||||
validator: {
|
||||
validate: {
|
||||
isNumeric: true,
|
||||
len: [1, 3],
|
||||
},
|
||||
@ -74,7 +68,7 @@ const api_log_Model = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 10,
|
||||
validator: {
|
||||
validate: {
|
||||
isNumeric: true,
|
||||
len: [1, 100],
|
||||
},
|
||||
@ -83,7 +77,7 @@ const api_log_Model = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 45,
|
||||
validator: {
|
||||
validate: {
|
||||
isString(value) {
|
||||
if (typeof value !== "string") {
|
||||
throw new Error("Referrer must be a string");
|
||||
@ -97,7 +91,7 @@ const api_log_Model = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 100,
|
||||
validator: {
|
||||
validate: {
|
||||
isString(value) {
|
||||
if (typeof value !== "string") {
|
||||
throw new Error("UserAgent must be a string");
|
||||
|
@ -11,7 +11,7 @@ const locationModel = sequelize.define(
|
||||
allowNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
validator: {
|
||||
validate: {
|
||||
isNumeric: true,
|
||||
},
|
||||
},
|
||||
@ -19,7 +19,7 @@ const locationModel = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 10,
|
||||
validator: {
|
||||
validate: {
|
||||
notEmpty: { msg: "Name cannot be empty" },
|
||||
len: [1, 20],
|
||||
/*
|
||||
@ -27,7 +27,8 @@ const locationModel = sequelize.define(
|
||||
"hello world" (contains a space)
|
||||
"hello@123" (contains a symbol)
|
||||
"" (empty string)
|
||||
|
||||
is: /^[a-z]+$/i, // matches this RegExp
|
||||
is: ["^[a-z]+$",'i'],
|
||||
*/
|
||||
is: ["^[a-z0-9]+$", "i"]
|
||||
},
|
||||
@ -36,16 +37,9 @@ const locationModel = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 10,
|
||||
validator: {
|
||||
validate: {
|
||||
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)
|
||||
|
||||
*/
|
||||
len: [1, 20],
|
||||
is: ["^[a-z0-9]+$", "i"]
|
||||
},
|
||||
},
|
||||
@ -53,17 +47,16 @@ const locationModel = sequelize.define(
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 100,
|
||||
validator: {
|
||||
validate: {
|
||||
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"]
|
||||
is: ["^[a-zA-Z0-9 ]+$", "i"]
|
||||
},
|
||||
},
|
||||
createdAt: {
|
||||
|
Reference in New Issue
Block a user