Improve error handling
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
import parseDomain from 'parse-domain';
|
||||
|
||||
export function stripSubdomain(hostname) {
|
||||
export function stripSubdomain(hostname: string) {
|
||||
const parsed = parseDomain(hostname);
|
||||
if (parsed.tld) return `${parsed.domain}.${parsed.tld}`;
|
||||
return parsed.domain;
|
||||
|
||||
Reference in New Issue
Block a user