catamphetamine / read-excel-file

Read *.xlsx files in a browser or Node.js. Parse to JSON with a strict schema.
https://catamphetamine.gitlab.io/read-excel-file/
MIT License
301 stars 52 forks source link

Accessing other row values in custom validation #112

Closed MachariaK closed 1 year ago

MachariaK commented 1 year ago

I want to access other row values when validating data. Is this possible? See code below:

const schema = { 'KRA Pin': { prop: 'kraPin', required: true, type: (value, row) => { console.log(row) // HOW CAN I ACCESS nssfNUMBER HERE? } }, 'NSSF Number': { prop: 'nssfNumber', required: true, }, }

catamphetamine commented 1 year ago

Hi. There’s no support for such validation in the library. That type of complex validation could be done after parsing data.

On Sun, 19 Mar 2023 at 10:20, Tim Kariuki @.***> wrote:

I want to access other row values when validating data. Is this possible? See code below:

const schema = { 'KRA Pin': { prop: 'kraPin', required: true, type: (value, row) => { console.log(row) // HOW CAN I ACCESS nssfNUMBER HERE? } }, 'NSSF Number': { prop: 'nssfNumber', required: true, }, }

— Reply to this email directly, view it on GitHub https://github.com/catamphetamine/read-excel-file/issues/112, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADUP3YEQHN5OCCFXYOI5QTW42XTBANCNFSM6AAAAAAV76GPFQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Deepakeon commented 8 months ago

Hi, if we do the validation after parsing data, how to get the row number and column name in which the validation failed?

catamphetamine commented 8 months ago

The errors list items have row and column indexes

On Wed, 28 Feb 2024 at 07:36, Deepak Singh @.***> wrote:

Hi, if we do the validation after parsing data, how to get the row number and column name in which the validation failed?

— Reply to this email directly, view it on GitHub https://github.com/catamphetamine/read-excel-file/issues/112#issuecomment-1968209873, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADUP3YSGI6OLJIRHIKHNKLYV2X3TAVCNFSM6AAAAAAV76GPFSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGIYDSOBXGM . You are receiving this because you commented.Message ID: @.***>