diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-12-28 15:49:23 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-12-28 15:49:23 +0100 |
commit | 67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677 (patch) | |
tree | bae6a9b0c3133c9cc38a2972222b5991f0cf614e /server/models/author.js | |
parent | 552cc9d646e78edae8b0fe61564d4e49db0b6206 (diff) | |
download | PeerTube-67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677.tar.gz PeerTube-67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677.tar.zst PeerTube-67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677.zip |
Server: add database field validations
Diffstat (limited to 'server/models/author.js')
-rw-r--r-- | server/models/author.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/server/models/author.js b/server/models/author.js index 493c2ca11..e0ac868ea 100644 --- a/server/models/author.js +++ b/server/models/author.js | |||
@@ -1,8 +1,19 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const customUsersValidators = require('../helpers/custom-validators').users | ||
4 | |||
1 | module.exports = function (sequelize, DataTypes) { | 5 | module.exports = function (sequelize, DataTypes) { |
2 | const Author = sequelize.define('Author', | 6 | const Author = sequelize.define('Author', |
3 | { | 7 | { |
4 | name: { | 8 | name: { |
5 | type: DataTypes.STRING | 9 | type: DataTypes.STRING, |
10 | allowNull: false, | ||
11 | validate: { | ||
12 | usernameValid: function (value) { | ||
13 | const res = customUsersValidators.isUserUsernameValid(value) | ||
14 | if (res === false) throw new Error('Username is not valid.') | ||
15 | } | ||
16 | } | ||
6 | } | 17 | } |
7 | }, | 18 | }, |
8 | { | 19 | { |