2022-10-03 05:19:33 +00:00
|
|
|
package domain
|
|
|
|
|
2022-10-23 06:20:48 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
)
|
2022-10-10 05:16:40 +00:00
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
var ErrNothingToUpdate = errors.New("nothing to update")
|
2022-10-03 05:19:33 +00:00
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
type TranslatableError interface {
|
2022-10-03 05:19:33 +00:00
|
|
|
error
|
2023-06-27 12:00:35 +00:00
|
|
|
Slug() string
|
|
|
|
Params() map[string]any
|
2022-10-03 05:19:33 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
type RequiredError struct {
|
2022-10-03 05:19:33 +00:00
|
|
|
Field string
|
2022-10-23 06:20:48 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
var _ TranslatableError = RequiredError{}
|
2022-10-23 06:20:48 +00:00
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
func (e RequiredError) Error() string {
|
|
|
|
return fmt.Sprintf("%s can't be blank", e.Field)
|
2022-10-23 06:20:48 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
func (e RequiredError) Slug() string {
|
|
|
|
return "required"
|
2022-10-23 06:20:48 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 12:00:35 +00:00
|
|
|
func (e RequiredError) Params() map[string]any {
|
|
|
|
return map[string]any{
|
|
|
|
"Field": e.Field,
|
|
|
|
}
|
2022-10-23 06:20:48 +00:00
|
|
|
}
|