Skip to content

Commit

Permalink
Fixes typanion error messages when they contain :
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanis authored Sep 27, 2023
1 parent 918d72f commit 158c1a0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions typanion/src/typanion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import type { Resolver } from './types';

const parseErrors = (errors: string[], parsedErrors: FieldErrors = {}) => {
return errors.reduce((acc, error) => {
const e = error.split(':');
const fieldIndex = error.indexOf(':');

acc[e[0].slice(1)] = {
message: e[1].trim(),
const field = error.slice(1, fieldIndex);
const message = error.slice(fieldIndex + 1).trim();

acc[field] = {
message,
} as FieldError;

return acc;
Expand Down

0 comments on commit 158c1a0

Please sign in to comment.