2018-12-04 13:58:38 -08:00
|
|
|
import { capitalize } from 'lodash'
|
2018-12-03 10:43:58 -08:00
|
|
|
|
|
|
|
export function humanizeErrors (errors) {
|
2018-12-04 13:58:38 -08:00
|
|
|
return Object.entries(errors).reduce((errs, [k, val]) => {
|
2022-07-31 02:35:48 -07:00
|
|
|
const message = val.reduce((acc, message) => {
|
|
|
|
const key = capitalize(k.replace(/_/g, ' '))
|
2018-12-03 10:43:58 -08:00
|
|
|
return acc + [key, message].join(' ') + '. '
|
|
|
|
}, '')
|
|
|
|
return [...errs, message]
|
|
|
|
}, [])
|
|
|
|
}
|