Check problem in a nested field in JSON

Hello,

I have this kind of JSON object
On client :
var link = {
label: $(’#label’).val(),
address: $(’#address’).val(),
misc: [{cat: selectedCatId},{lang: “FR”},{lang: “EN”}],
submitted: new Date(),
priv: 0,
clicks: 0,
clicked: new Date(),
order: 0,
proprio: “X”
};

On server :
check(link, {
label: String,
address: String,
misc: [Object],
submitted: Date,
priv: Number,
clicks: Number,
clicked: Date,
order: Number,
proprio:String
});

misc: [Object], does not match. Do you have a solution ?

Thank you

Probably because its an array, not an array of objects.

Thank you Goatic, this check package is useful but not easy to use.
When I put [Object], I have this error message :
Expected object, got string in field misc[1]
When I put [String], I have this error message :
Expected string, got object in field misc[0]

I feel stuck :frowning:

I don’t think the check package is the issue here. For example, go to meteor.com, open up your browser console, and run the following:

check({ misc: [{cat: '123'}, {lang: 'FR'}, {lang: 'EN'}]}, { misc: [Object] })

This will pass properly. I think you should add a console.log(link) just before you call check on the server, to make sure link contains what you think it does.

Yes you are right Hwillson, thank you. I have “misc: Array[2]” displayed in my console. So I have to go another direction.