Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #371 from beabee-communityrm/chore/add-validation-…
Browse files Browse the repository at this point in the history
…logging

chore: add logging to help trace component validation problems
  • Loading branch information
wpf500 authored Feb 28, 2024
2 parents f485b66 + 2e1f583 commit adf878e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/api/dto/CalloutFormDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import {
validate
} from "class-validator";

import { log as mainLogger } from "@core/logging";

const log = mainLogger.child({ app: "callout-form-validation" });

// content

const inputTypes = [
Expand Down Expand Up @@ -178,11 +182,12 @@ function IsComponent(validationOptions?: ValidationOptions) {
validator: {
async validate(value: unknown) {
if (typeof value !== "object" || value === null) return false;
const error = await validate(value, {
const errors = await validate(value, {
whitelist: false,
forbidUnknownValues: true
});
return error.length === 0;
log.notice("Component validation errors", { errors });
return errors.length === 0;
},
defaultMessage: buildMessage(
(eachPrefix) => eachPrefix + "$property must be a valid component",
Expand Down

0 comments on commit adf878e

Please sign in to comment.