diff options
| author | syuilo⭐️ <Syuilotan@yahoo.co.jp> | 2017-03-03 19:54:40 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-03 19:54:40 +0900 |
| commit | 3ce6601f0436da23589384990dfb6c12cec5a5b4 (patch) | |
| tree | b7b9cc14d9787f06c72d013bc25690a9470e6bbe /src/api/models | |
| parent | fix(package): update whatwg-fetch to version 2.0.3 (diff) | |
| parent | done (diff) | |
| download | misskey-3ce6601f0436da23589384990dfb6c12cec5a5b4.tar.gz misskey-3ce6601f0436da23589384990dfb6c12cec5a5b4.tar.bz2 misskey-3ce6601f0436da23589384990dfb6c12cec5a5b4.zip | |
Merge pull request #232 from syuilo/#226
#226、あとTypeScriptにした
Diffstat (limited to 'src/api/models')
| -rw-r--r-- | src/api/models/app.ts | 4 | ||||
| -rw-r--r-- | src/api/models/messaging-message.ts | 5 | ||||
| -rw-r--r-- | src/api/models/post.ts | 4 | ||||
| -rw-r--r-- | src/api/models/user.ts | 8 |
4 files changed, 21 insertions, 0 deletions
diff --git a/src/api/models/app.ts b/src/api/models/app.ts index a947d88e4c..bf5dc80c2c 100644 --- a/src/api/models/app.ts +++ b/src/api/models/app.ts @@ -7,3 +7,7 @@ const collection = db.get('apps'); (collection as any).index('secret'); // fuck type definition export default collection as any; // fuck type definition + +export function isValidNameId(nameId: string): boolean { + return typeof nameId == 'string' && /^[a-zA-Z0-9\-]{3,30}$/.test(nameId); +} diff --git a/src/api/models/messaging-message.ts b/src/api/models/messaging-message.ts index cad6823cb8..50955d7fb0 100644 --- a/src/api/models/messaging-message.ts +++ b/src/api/models/messaging-message.ts @@ -1,3 +1,8 @@ import db from '../../db/mongodb'; export default db.get('messaging_messages') as any; // fuck type definition + +export function isValidText(text: string): boolean { + return text.length <= 1000 && text.trim() != ''; +} + diff --git a/src/api/models/post.ts b/src/api/models/post.ts index ab29187251..baab63f991 100644 --- a/src/api/models/post.ts +++ b/src/api/models/post.ts @@ -1,3 +1,7 @@ import db from '../../db/mongodb'; export default db.get('posts') as any; // fuck type definition + +export function isValidText(text: string): boolean { + return text.length <= 1000 && text.trim() != ''; +} diff --git a/src/api/models/user.ts b/src/api/models/user.ts index 5ab39d7c92..cd16459891 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -19,6 +19,14 @@ export function isValidName(name: string): boolean { return typeof name == 'string' && name.length < 30 && name.trim() != ''; } +export function isValidDescription(description: string): boolean { + return typeof description == 'string' && description.length < 500 && description.trim() != ''; +} + +export function isValidLocation(location: string): boolean { + return typeof location == 'string' && location.length < 50 && location.trim() != ''; +} + export function isValidBirthday(birthday: string): boolean { return typeof birthday == 'string' && /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday); } |