diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-03 08:56:07 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-03 08:56:07 +0900 |
| commit | dc45055f2ffcea2369f12d104999746220b22c90 (patch) | |
| tree | d3ec8f4a03076fe804c906cd60656e197f3010f2 /src/api/endpoints/i/update.ts | |
| parent | wip (diff) | |
| download | misskey-dc45055f2ffcea2369f12d104999746220b22c90.tar.gz misskey-dc45055f2ffcea2369f12d104999746220b22c90.tar.bz2 misskey-dc45055f2ffcea2369f12d104999746220b22c90.zip | |
wip
Diffstat (limited to '')
| -rw-r--r-- | src/api/endpoints/i/update.ts (renamed from src/api/endpoints/i/update.js) | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/api/endpoints/i/update.js b/src/api/endpoints/i/update.ts index 4abb4fcb7b..1e46315ceb 100644 --- a/src/api/endpoints/i/update.js +++ b/src/api/endpoints/i/update.ts @@ -3,7 +3,7 @@ /** * Module dependencies */ -import * as mongo from 'mongodb'; +import it from '../../it'; import User from '../../models/user'; import { isValidName, isValidBirthday } from '../../models/user'; import serialize from '../../serializers/user'; @@ -23,18 +23,9 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, rej) => { // Get 'name' parameter - const name = params.name; - if (name !== undefined && name !== null) { - if (typeof name != 'string') { - return rej('name must be a string'); - } - - if (!isValidName(name)) { - return rej('invalid name'); - } - - user.name = name; - } + const [name, nameErr] = it(params.name).expect.string().validate(isValidName).qed(); + if (nameErr) return rej('invalid name param'); + user.name = name; // Get 'description' parameter const description = params.description; |