Advertisement
Guest User

Untitled

a guest
Jan 12th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// user
  2.   username:{
  3.         type:DataTypes.STRING,
  4.         validate: {
  5.           min: {
  6.               args: 1,
  7.               msg: 'user.username.min.'
  8.           },
  9.           max: {
  10.               args: 30,
  11.               msg: 'Username must less than 40 characters.'
  12.           },
  13.           notEmpty: {
  14.               args:true,
  15.               msg: "user.username.empty",
  16.               // errorCo:2010
  17.           },
  18.             unique: {
  19.                 args: true,
  20.                 message: 'user.username.unique',
  21.                 fields: [sequelize.fn('lower', sequelize.col('username'))]
  22.             },
  23.           is: {
  24.               args: /^[A-Za-z][A-Za-z0-9-]+$/i, // must start with letter and only have letters, numbers, dashes
  25.               msg: 'Username must no spaces'
  26.           },
  27.         },
  28.   },
  29.     password: {
  30.         type:DataTypes.STRING,
  31.         min:{
  32.             args:6,
  33.             msg:
  34.                 "Password min length is 6 characters"
  35.         },
  36.         max:{
  37.             args:30,
  38.             msg:
  39.                 "Password maximum length must be 30 characters"
  40.         },
  41.         is:{
  42.             args:['/^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{6,}$','i'],
  43.             msg:'Password should contain at least one letter and one digit'
  44.         }
  45.     },
  46.     password_comfirm: {
  47.       type:DataTypes.STRING,
  48.     },
  49.     email: {
  50.         type: DataTypes.STRING,
  51.         lowercase:true,
  52.         validate: {
  53.             // is: ['^\S+(?: \S+)*$','u'],
  54.               len: {
  55.                   args: [0, 129],
  56.                   msg:
  57.                       "Email address max 129 characters in length"
  58.  
  59.               },
  60.             max: {
  61.                 args: 129,
  62.                 msg: "Email address max 129 characters in length"
  63.             },
  64.             // notEmpty: true,
  65.             notEmpty: {
  66.                   args:true,
  67.                 msg: "Email address not empty"
  68.             },
  69.             isEmail: {
  70.                   args:true,
  71.                   msg: "Email address must be valid"
  72.               },
  73.           },
  74.           unique: {
  75.             args: true,
  76.             msg: 'Looks like you already have an account with this email address. Please try to login.',
  77.             // fields: [sequelize.fn('lower', sequelize.col('email'))]
  78.     },
  79.       },
  80.     dob:{
  81.         type: DataTypes.DATE,
  82.         validate:{
  83.             min:{
  84.                 // args:
  85.             }
  86.         }
  87.     },
  88.  
  89. //comment
  90.  user_id: {
  91.             type:DataTypes.INTEGER,
  92.             foreignKey:true,
  93.             validate:{
  94.                 notEmpty: {
  95.                     args:true,
  96.                     msg: "user_id not empty",
  97.                 },
  98.                 isInt: {
  99.                     args:true,
  100.                     msg: "type user_id not mask",
  101.                 }
  102.             },
  103.         },
  104.     content: DataTypes.STRING,
  105.     feed_id: {
  106.         type:DataTypes.INTEGER,
  107.                 validate:{
  108.             notEmpty: {
  109.                 args:true,
  110.                         msg: "feed_id not empty",
  111.             },
  112.             isInt: {
  113.                 args:true,
  114.                         msg: "feed_id not found",
  115.             }
  116.         },
  117.     },
  118. /// like
  119.   user_id: {
  120.           type:DataTypes.INTEGER,
  121.           validate:{
  122.               notEmpty: {
  123.                   args:true,
  124.                   msg: "user_id not empty",
  125.               },
  126.               isInt: {
  127.                   args:true,
  128.                   msg: "user_id not found",
  129.               }
  130.           },
  131.       },
  132.       type: {
  133.           type:DataTypes.STRING,
  134.           validate:{
  135.               notEmpty: true,
  136.           }
  137.       },
  138.     feed_id: {
  139.         type:DataTypes.INTEGER,
  140.         validate:{
  141.             notEmpty: {
  142.                 args:true,
  143.                 msg: "feed_id not empty",
  144.             },
  145.             isInt: {
  146.                 args:true,
  147.                 msg: "feed_id not found",
  148.             }
  149.         },
  150.     },
  151. /// post feed
  152.   categories_id: {
  153.       type:DataTypes.INTEGER,
  154.         notEmpty: {
  155.             args:true,
  156.             msg: "categories_id not empty",
  157.         },
  158.         isInt: true,
  159.     },
  160.     user_id: {
  161.         type:DataTypes.INTEGER,
  162.         foreignKey:true,
  163.         validate:{
  164.             notEmpty: {
  165.                 args:true,
  166.                 msg: "user_id not empty",
  167.             },
  168.             isInt: {
  169.                 args:true,
  170.                 msg: "user_id not found",
  171.             }
  172.         },
  173.     },
  174.     content:{
  175.         type:DataTypes.TEXT,
  176.         notEmpty: {
  177.             args:true,
  178.             msg: "content not empty",
  179.         },
  180.     },
  181. //report
  182.  reason: {
  183.         type:DataTypes.STRING,
  184.         validate:{
  185.             notEmpty: {
  186.                 args:true,
  187.                 msg: "reason not empty",
  188.             },
  189.         },
  190.     },
  191.     message:{
  192.         type:DataTypes.TEXT,
  193.         validate:{
  194.             notEmpty: {
  195.                 args:true,
  196.                 msg: "message not empty",
  197.             },
  198.         },
  199.     },
  200.     feed_id:{
  201.         type:DataTypes.INTEGER,
  202.         validate:{
  203.             notEmpty: {
  204.                 args:true,
  205.                 msg: "feed_id not empty",
  206.             },
  207.             isInt: {
  208.                 args:true,
  209.                 msg: "feed_id not found",
  210.             }
  211.         },
  212.     },
  213.     user_id: {
  214.         type:DataTypes.INTEGER,
  215.         validate:{
  216.             notEmpty: {
  217.                 args:true,
  218.                 msg: "user_id not empty",
  219.             },
  220.             isInt: {
  221.                 args:true,
  222.                 msg: "user_id not found",
  223.             }
  224.         },
  225.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement