akkoma-fe/src/modules/errors.js

13 lines
342 B
JavaScript
Raw Normal View History

import { capitalize } from 'lodash'
export function humanizeErrors (errors) {
return Object.entries(errors).reduce((errs, [k, val]) => {
let message = val.reduce((acc, message) => {
let key = capitalize(k.replace(/_/g, ' '))
return acc + [key, message].join(' ') + '. '
}, '')
return [...errs, message]
}, [])
}
2019-04-10 18:48:42 +00:00