Skip to content

Commit

Permalink
Merge pull request #74 from formio/fix-json-and-custom-validation-err…
Browse files Browse the repository at this point in the history
…ors-response

Fix json and custom validation errors response
  • Loading branch information
travist authored Apr 5, 2024
2 parents 985245f + 1ccd19e commit 46b94d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/process/validation/rules/validateCustom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export const validateCustomSync: RuleFnSync = (context: ValidationContext) => {
return null;
}

return new FieldError(typeof isValid === 'string' ? isValid : 'custom', {...context, hasLabel: false });
return new FieldError(typeof isValid === 'string' ? isValid : 'custom', {
...context,
hasLabel: false,
setting: customValidation,
});
};


Expand Down
5 changes: 4 additions & 1 deletion src/process/validation/rules/validateJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export const validateJsonSync: RuleFnSync = (context: ValidationContext) => {
}
return valid === true
? null
: new FieldError(valid || 'jsonLogic', context);
: new FieldError(valid || 'jsonLogic', {
...context,
setting: func,
});
};

export const validateJsonInfo: ProcessorInfo<ValidationContext, FieldError | null> = {
Expand Down
2 changes: 1 addition & 1 deletion src/process/validation/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const interpolateErrors = (errors: FieldError[], lang: string = 'en') =>
level: error.level,
path: paths,
context: {
validator: errorKeyOrMessage || context.processor,
validator: context.processor,
hasLabel: context.hasLabel,
key: context.component.key,
label: context.component.label || context.component.placeholder || context.component.key,
Expand Down

0 comments on commit 46b94d3

Please sign in to comment.