Last active
July 5, 2019 00:11
-
-
Save surajp/10f2a286840f88cda2fbbb82950d4a1f to your computer and use it in GitHub Desktop.
Regex validation for JSON Array
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
const colheaders = Object.keys(rows[0]); | |
const errors=[]; | |
const regexpArray=[]; | |
rows.forEach((row,rowindex)=>{ | |
errors[rowindex]=[]; | |
Object.values(row).forEach((val,colindex)=>{ | |
if(regexpArray[colindex] && regexpArray[colindex].test(val)){ | |
errors[rowindex].push(colheaders[colindex]); | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment