Skip to content

Commit

Permalink
chore: apply code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jajugoguma committed Nov 16, 2023
1 parent b532266 commit 2699092
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions packages/toast-ui.grid/src/query/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,36 @@ export function getInvalidRows(store: Store, rowKeys?: RowKey[]) {
const invalidRows: InvalidRow[] = [];

data.rawData.forEach((row, rowIndex) => {
if (!isObservable(row) && (!rowKeys || rowKeys.includes(row.rowKey))) {
const needToValidateRow = !rowKeys || rowKeys.includes(row.rowKey);

if (!isObservable(row) && needToValidateRow) {
makeObservable(store, rowIndex, true);
}
});

data.viewData.forEach(({ rowKey, valueMap }) => {
if (!rowKeys || rowKeys?.includes(rowKey)) {
const invalidColumns = column.validationColumns.filter(
({ name }) => !!valueMap[name].invalidStates.length
);

if (invalidColumns.length) {
const errors = invalidColumns.map(({ name }) => {
const { invalidStates } = valueMap[name];

return {
columnName: name,
errorInfo: invalidStates,
errorCode: invalidStates.map(({ code }) => code),
};
});

invalidRows.push({ rowKey, errors });
}
const needToValidateRow = !rowKeys || rowKeys.includes(rowKey);

if (!needToValidateRow) {
return;
}

const invalidColumns = column.validationColumns.filter(
({ name }) => !!valueMap[name].invalidStates.length
);

if (invalidColumns.length) {
const errors = invalidColumns.map(({ name }) => {
const { invalidStates } = valueMap[name];

return {
columnName: name,
errorInfo: invalidStates,
errorCode: invalidStates.map(({ code }) => code),
};
});

invalidRows.push({ rowKey, errors });
}
});

Expand Down

0 comments on commit 2699092

Please sign in to comment.