mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
This included removing some internal version constraints. It would be nice if package A could say "use B@2.0.0" (when both have changed), but when they're both in the release, we need to make a release that has a B@2.0.0-rc in it, which doesn't match that constraint. Fortunately, constraints aren't necessary within a release anyway.
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.