package mapper

import (
	"errors"

	validation "github.com/go-ozzo/ozzo-validation/v4"
)

func ToErrorsMap(err error) map[string]string {
	res := make(map[string]string)

	var validationErrors validation.Errors
	if errors.As(err, &validationErrors) {
		for field, msg := range validationErrors {
			res[field] = msg.Error()
		}
	}

	return res
}
