/
githubmirror
/
socket.io
Обзор
Документация
Войти
/
githubmirror
/
socket.io
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/basic-crud-application/server/lib/util.ts
24 строки
585 B
Damien Arrachequesne
docs: fix basic crud example
17 дек 2021, 01:00
Не верифицирован
17 дек 2021, 01:00
c196689
Код
Авторство
О чём код?
import { ValidationErrorItem } from "joi"; export enum Errors { ENTITY_NOT_FOUND = "entity not found", INVALID_PAYLOAD = "invalid payload", } const errorValues: string[] = Object.values(Errors); export function sanitizeErrorMessage(message: any) { if (typeof message === "string" && errorValues.includes(message)) { return message; } else { return "an unknown error has occurred"; } } export function mapErrorDetails(details: ValidationErrorItem[]) { return details.map((item) => ({ message: item.message, path: item.path, type: item.type, })); }