We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6630710 commit 682653eCopy full SHA for 682653e
api/server/methods.ts
@@ -1,9 +1,19 @@
1
import { Chats } from './collections/chats';
2
import { Messages } from './collections/messages';
3
import { MessageType } from './models';
4
+import { check, Match } from 'meteor/check';
5
+
6
+const nonEmptyString = Match.Where((str) => {
7
+ check(str, String);
8
+ return str.length > 0;
9
+});
10
11
Meteor.methods({
12
addMessage(type: MessageType, chatId: string, content: string) {
13
+ check(type, Match.OneOf(String, [ MessageType.TEXT ]));
14
+ check(chatId, nonEmptyString);
15
+ check(content, nonEmptyString);
16
17
const chatExists = !!Chats.collection.find(chatId).count();
18
19
if (!chatExists) {
0 commit comments