From abfb36bcdb25ba11bda9892ec473970fc29506bb Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Feb 2017 19:39:34 +0900 Subject: Fix bug --- src/api/models/user.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/api/models/user.ts') diff --git a/src/api/models/user.ts b/src/api/models/user.ts index 30805e4b63..c8c187c509 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -8,9 +8,14 @@ const collection = db.get('users'); export default collection as any; // fuck type definition export function validateUsername(username: string): boolean { - return /^[a-zA-Z0-9\-]{3,20}$/.test(username); + return typeof username == 'string' && /^[a-zA-Z0-9\-]{3,20}$/.test(username); +} + +export function validatePassword(password: string): boolean { + return typeof password == 'string' && password != ''; } export function isValidBirthday(birthday: string): boolean { - return /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday); + return typeof birthday == 'string' && /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday); +} } -- cgit v1.2.3-freya