Why am I getting, "check is not defined" in Meteor?

When I had this method in /both/methods.js:

Meteor.methods({
    'insertPerson': function(firstname, lastname, streetaddr1, streetaddr2, placename, stateorprov, zipcode, emailaddr, phone) {
        console.log('insertPerson reached'); // TODO: Remove before deploying
        check(firstname, String);
        check(lastname, String);
        check(streetaddr1, String);
        check(streetaddr2, String);
        check(placename, String);
        check(stateorprov, String);
        check(zipcode, String);
        check(emailaddr, String);
        check(phone, String);

        People.insert({
            per_firstname: firstname,
            per_lastname: lastname,
            per_streetaddr1: streetaddr1,
            per_streetaddr2: streetaddr2,
            per_placename: placename,
            per_stateorprov: stateorprov,
            per_zipcode: zipcode,
            per_emailaddr: emailaddr,
            per_phone: phone,
            per_createdBy: this.userId
        });
    }
});

…it failed to work - no Document was entered. CDT said, “check is not defined”

Say what?!? check(value, pattern) is a common Meteor sanity check pattern.

Once I commented out all the check()s, though, sure enough, the Document was inserted into the database. So what gives with the unrecognition of check(value, pattern)?

Is check listed in your .meteor/packages file?

If not, meteor add check.

2 Likes