-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into DEV-1469-reset-signup-form-errors
- Loading branch information
Showing
4 changed files
with
21 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"nextjs-website": patch | ||
--- | ||
|
||
[DEV-1545] Add custom PathReporter to improve readability of errors raised by decode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as t from 'io-ts'; | ||
|
||
const getMessage = (error: t.ValidationError): string => { | ||
if (error.message) { | ||
return error.message; | ||
} else { | ||
const jsonPath = error.context.map(({ key }) => `${key}`).join('/'); | ||
const expected = error.context[error.context.length - 1].type.name; | ||
return `Invalid value ${error.value} supplied to '${jsonPath}', expected type ${expected}`; | ||
} | ||
}; | ||
|
||
export const failure = (errors: t.Errors): ReadonlyArray<string> => | ||
errors.map(getMessage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters