Skip to content

Row Index is wrong when fields are mismatch #130

@ambangeles

Description

@ambangeles

This is the csv I uploaded:
template (6).csv
image

In row 5 there's a mismatch in the fields since it only has 3 data. but the inValidData returned this:
image

It says that the rowIndex 4 has the fields mismatch but actually it should be row 5.
It also happened in row 10 and 12 the field mismatch error should be in in row 10 and 12 not 9 and 11.

Here is my config:
const config: ValidatorConfig = {
headers: [
{
name: "First Name",
inputName: "first_name",
required: true,
validate(field) {
return first_name_schema.safeParse(field).success;
},
},
{
name: "Last Name",
inputName: "last_name",
validate(field) {
return last_name_schema.safeParse(field).success;
},
},
{
name: "Phone Number",
inputName: "phone_number",
validate(field) {
return phone_number_schema.safeParse(field).success;
},
dependentValidate(field, row: string[]) {
if (!field && !row[THREE]) {
return false;
}

			return true;
		},
	},
	{
		name: "Email Address",
		inputName: "email_address",
		validate(field) {
			return email_address_schema.safeParse(field).success;
		},
		dependentValidate(field, row: string[]) {
			if (!field && !row[TWO]) {
				return false;
			}

			return true;
		},
	},
],

};
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions