2018-12-05 08:58:38 +11:00
|
|
|
import { capitalize } from 'lodash'
|
2018-12-04 05:43:58 +11:00
|
|
|
|
|
|
|
export function humanizeErrors (errors) {
|
2018-12-05 08:58:38 +11:00
|
|
|
return Object.entries(errors).reduce((errs, [k, val]) => {
|
|
|
|
let message = val.reduce((acc, message) => {
|
2018-12-04 05:43:58 +11:00
|
|
|
let key = capitalize(k.replace(/_/g, ' '))
|
|
|
|
return acc + [key, message].join(' ') + '. '
|
|
|
|
}, '')
|
|
|
|
return [...errs, message]
|
|
|
|
}, [])
|
|
|
|
}
|
|
|
|
|