Files
meteor/packages/check
David Glasser 4daaa76b12 METEOR@1.0.4
2015-03-17 13:06:07 -07:00
..
2015-01-07 19:04:54 -08:00
2015-03-17 13:06:07 -07:00
2014-10-24 10:13:59 -07:00

check

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.