Files
meteor/packages/check
Jesse Rosenberger 4d861735c5 Export check as a named function declaration for JSDoc.
The change made in a30f42c4ac switched
from CommonJS to ECMAScript export notation.

It seems JSDoc isn't smart enough to make the same association as it did with
the previous notation as it does for an anon. function expression `export`-ed
as a `const`ant.  We could annotate this with `@function check`, but it seems
reasonable to just export a function declaration directly, which JSDoc will
understand.

This, along with ababb18aef, corrects the
failure of docs generation originally discovered in:
8f7ceb5de5.

Refs: https://github.com/meteor/meteor/pull/9593
2018-01-30 22:34:59 +02:00
..
2016-08-30 15:40:14 -07:00

check

Source code of released version | Source code of development version


check is a lightweight package for argument checking and general pattern matching. Use it like this:

Meteor.publish("chats-in-room", function (roomId) {
  // Make sure roomId is a string, not an arbitrary mongo selector object.
  check(roomId, String);
  return Chats.find({room: roomId});
});

Meteor.methods({addChat: function (roomId, message) {
  check(roomId, String);
  check(message, {
    text: String,
    timestamp: Date,
    // Optional, but if present must be an array of strings.
    tags: Match.Optional([String])
  });

  // ... do something with the message ...
}});

For more details see the check section of the Meteor docs.