A utility for processing a JSON encoded array of objects.
Attached is an imaginary example set of data a customer might need to migrate from one system to another. It's a JSON encoded array of objects. The customer understands some of the data might be bad and want to know which records are invalid so they can ensure the new system will only have valid data. Write a program that will read in the data and mark any record:
- That are a duplicate of another record
name
field is null, missing, or blankaddress
field is null, missing, or blankzip
is null, missing, or an invalid U.S. zipcode
- A recent Node Js version (this repo was developed using 14.16.0)
- Clone the repository via
git clone git@github.com:gravyboat/syniti-take-home.git
- Change in to the directory and install dependencies via
npm install
This repository is using Typescript and ts-jest.
Tests can be run via npm t
.
For the provided test data use the following steps:
npm run build
node .\dist\validateData.js
Data will be output in to the output
directory as an example.
For your own data if you want to write to a file:
// make sure you have the appropriate path since this isn't a module
import validateData from 'validateData'
validateData('pathToInputFile', 'pathToValidOutputFile', 'pathToInvalidOutputFile');
For your own data if you don't want to write to a file:
// make sure you have the appropriate path since this isn't a module
import validateData from 'validateData'
validateData('pathToInputFile');
Both calls to the function will return an array of the valid and invalid data arrays.