Improve error handling

This commit is contained in:
Tom Moor
2018-11-03 21:47:46 -07:00
parent 21b1c0747c
commit 6418712c47
5 changed files with 27 additions and 8 deletions

View File

@@ -21,9 +21,18 @@ const Team = sequelize.define(
allowNull: true,
validate: {
isLowercase: true,
is: [/^[a-z\d-]+$/, 'i'],
len: [4, 32],
notIn: [RESERVED_SUBDOMAINS],
is: {
args: [/^[a-z\d-]+$/, 'i'],
msg: 'Must be only alphanumeric and dashes',
},
len: {
args: [4, 32],
msg: 'Must be between 4 and 32 characters',
},
notIn: {
args: [RESERVED_SUBDOMAINS],
msg: 'You chose a restricted word, please try another.',
},
},
unique: true,
},