Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions chapter04.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,15 @@ function aMap(obj) {

var checkCommand = checker(validator("must be a map", aMap));

function hasKeys() {
function hasKeysValidator() {
var KEYS = _.toArray(arguments);
var message = cat(["Must have values for keys:"], KEYS).join(" ");

var fun = function(obj) {
return validator(message, function(obj) {
return _.every(KEYS, function(k) {
return _.has(obj, k);
});
};

fun.message = cat(["Must have values for keys:"], KEYS).join(" ");
return fun;
});
}

var checkCommand = checker(validator("must be a map", aMap), hasKeys('msg', 'type'));
var checkCommand = checker(validator("must be a map", aMap), hasKeysValidator('msg', 'type'));