I am trying to perform validation on a json object. But it seems that the method ispoQuantityInvalid
method is not getting called at all.
selectedRows = [{
"itemNumber": "",
"lineNumber": 1,
"description": "PUMP,COMPLETE, P/N E12LYTFS-137",
"uom": "",
"poQuantity": "1",
"recievedQuantity": "3",
"isMatched": false,
"p2PLineItemId": "168512",
"quantityUnitPrice": "1",
"buyerItemNumber": null
}];
ispoQuantityInvalid = () => (element, index, array) => {
alert() //not getting called.
return this.isEmpty(element.poQuantity);
}
console.log(this.selectedRows)
if (this.selectedRows.some(this.ispoQuantityInvalid)) {
console.log('po qty is null or empty') //always gets called.
return;
}
isEmpty = (value) => {
return (value == null || value.length === 0 || value === '' || value == 0);
}
- Even though
poQuantity
is not null or empty or 0, it is failing validation. - It seems
ispoQuantityInvalid
method is not getting called at all. I don't see alert.
What am I missing here? It seems to be a scope issue. But I am using arrow function that is supposed to not cause this issue right?