JSONSelect icon indicating copy to clipboard operation
JSONSelect copied to clipboard

Selected values manipulator in forEach || JSONSelect.map() required.

Open dead1 opened this issue 11 years ago • 0 comments

I'm trying to validate nodejs app POST input with JSONSelect. It would be nice if I could also manipulate the selected data. Like in the following code:

JSONSelect.forEach(
    ".points_to_delete .id," +
    ".points_to_update .status," +
    ".points_to_update .task_id," +
    ".points_to_update .warning",
    args,
function(item,itemManipulator)
{
    if(require('validator').isNumeric(item))
    {
        itemManipulator.setItemValue(parseInt(item))
    }
    else
    {
        throw Error("Item is not numeric!")
    }
})

Probably, it would be better to create JSONSelect.map() for this purposes. Thank you.

dead1 avatar Feb 26 '14 19:02 dead1