Skip to content

Commit

Permalink
Merge pull request #78 from formio/FIO-8210-fix-nested-form-validation
Browse files Browse the repository at this point in the history
FIO-8210: fix nested form validation
  • Loading branch information
travist authored Apr 12, 2024
2 parents eac8210 + 179c5ee commit 5828e5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/process/filter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export const filterPostProcess: ProcessorFnSync<FilterScope> = (context: FilterC
if (scope.filter[path]) {
let value = get(submission?.data, path);
if (isObject(value) && isObject(scope.filter[path])) {
value = {...value, ...scope.filter[path]}
if ((value as any).data) {
value = {...value, ...scope.filter[path], data: (value as any)?.data}
} else {
value = {...value, ...scope.filter[path]}
}
}
set(filtered, path, value);
}
Expand Down
3 changes: 2 additions & 1 deletion src/process/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getComponentAbsolutePath, getComponentPath } from "utils/formUtil";
import { getErrorMessage } from "utils/error";
import { FieldError } from "error";
import { ConditionallyHidden, isConditionallyHidden, isCustomConditionallyHidden, isSimpleConditionallyHidden } from "processes/conditions";
import { validate } from 'fast-json-patch';

// Cleans up validation errors to remove unnessesary parts
// and make them transferable to ivm.
Expand Down Expand Up @@ -278,7 +279,7 @@ export const validateProcessSync: ValidationProcessorFnSync = (context) => {
return;
}
if (component.truncateMultipleSpaces && value && typeof value === 'string') {
value = value.trim().replace(/\s{2,}/g, ' ');
set(data, path, value.trim().replace(/\s{2,}/g, ' '));
}
for (const rule of rulesToExecute) {
try {
Expand Down

0 comments on commit 5828e5a

Please sign in to comment.