Created
November 13, 2013 11:16
-
-
Save mrutid/7447424 to your computer and use it in GitHub Desktop.
Hace lo que tiene que hacer, aunque no me gusta como acumulo.Prefiero un array de cadenas. Pasan los test de checkeo pero he roto algo... que no deberia tener que ver....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
for (var field in fields) { | |
if (typeof body[fields[field]] == 'undefined') { | |
callback({ | |
code: "FIELDS_MISSING", | |
field: fields[field] | |
}); | |
return; | |
} | |
} | |
*/ | |
function checkField(field) { | |
return (typeof body[field] === 'undefined'); | |
} | |
function packErrors(prev, current) { | |
prev += current; | |
return prev; | |
} | |
var errors = fields.filter(checkField).reduce(packErrors, ''); | |
if (errors !== '') { | |
callback({ | |
code: "FIELDS_MISSING", | |
field: errors | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment