Skip to content

Commit 67ae3de

Browse files
committed
fix errormessage
1 parent d996af7 commit 67ae3de

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

packages/core/src/reducers/core.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,23 +312,22 @@ const getInvalidProperty = (error: ErrorObject): string | undefined => {
312312

313313
export const getControlPath = (error: ErrorObject) => {
314314
const dataPath = (error as any).dataPath;
315+
console.log("datapath: ",dataPath);
315316
// older AJV version
316317
if (dataPath) {
317-
return dataPath.replace(/\//g, '.').substr(1);
318+
return dataPath.split("/\//g").filter((e: string) =>e!=="");
318319
}
319320
// dataPath was renamed to instancePath in AJV v8
320-
var controlPath: string = error.instancePath;
321-
322321
// change '/' chars to '.'
323-
controlPath = controlPath.replace(/\//g, '.');
322+
console.log("instancePath: ",error.instancePath);
323+
var controlPath: string[] = error.instancePath.split("/").filter(e=> e!=="");
324324

325325
const invalidProperty = getInvalidProperty(error);
326-
if (invalidProperty !== undefined && !controlPath.endsWith(invalidProperty)) {
327-
controlPath = `${controlPath}.${invalidProperty}`;
326+
if (invalidProperty !== undefined && controlPath && controlPath[controlPath.length]!==invalidProperty) {
327+
controlPath.push(invalidProperty);
328328
}
329329

330-
// remove '.' chars at the beginning of paths
331-
controlPath = controlPath.replace(/^./, '');
330+
console.log("returnedPath: ",controlPath);
332331
return controlPath;
333332
}
334333

@@ -400,6 +399,7 @@ const getErrorsAt = (
400399
errorsAt(instancePath, schema, matchPath)(state.validationMode === 'ValidateAndHide' ? [] : state.errors);
401400

402401
export const errorAt = (instancePath: string[], schema: JsonSchema) =>
403-
getErrorsAt(instancePath, schema, path => path === instancePath);
402+
getErrorsAt(instancePath, schema, p => {
403+
return p.length === instancePath.length && p.every((element,i) => element === instancePath[i])});
404404
export const subErrorsAt = (instancePath: string[], schema: JsonSchema) =>
405405
getErrorsAt(instancePath, schema, path => contains(path,instancePath));

packages/material/src/complex/MaterialTableControl.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const getValidColumnProps = (scopedSchema: JsonSchema) => {
125125
);
126126
}
127127
// primitives
128-
return [''];
128+
return [];
129129
};
130130

131131
export interface EmptyTableProps {
@@ -176,7 +176,8 @@ const ctxToNonEmptyCellProps = (
176176
errorsAt(
177177
path,
178178
ownProps.schema,
179-
p => p === path
179+
p => {
180+
return p.length === path.length && p.every((element,i) => element === path[i])}
180181
)(ctx.core.errors).map((error: ErrorObject) => error.message)
181182
)
182183
);

0 commit comments

Comments
 (0)