aboutsummaryrefslogtreecommitdiff
path: root/internal/ui/form
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ui/form')
-rw-r--r--internal/ui/form/api_key.go6
-rw-r--r--internal/ui/form/auth.go6
-rw-r--r--internal/ui/form/settings.go10
-rw-r--r--internal/ui/form/subscription.go16
-rw-r--r--internal/ui/form/user.go16
5 files changed, 27 insertions, 27 deletions
diff --git a/internal/ui/form/api_key.go b/internal/ui/form/api_key.go
index 1eb754bc..b87322a5 100644
--- a/internal/ui/form/api_key.go
+++ b/internal/ui/form/api_key.go
@@ -6,7 +6,7 @@ package form // import "miniflux.app/v2/internal/ui/form"
import (
"net/http"
- "miniflux.app/v2/internal/errors"
+ "miniflux.app/v2/internal/locale"
)
// APIKeyForm represents the API Key form.
@@ -15,9 +15,9 @@ type APIKeyForm struct {
}
// Validate makes sure the form values are valid.
-func (a APIKeyForm) Validate() error {
+func (a APIKeyForm) Validate() *locale.LocalizedError {
if a.Description == "" {
- return errors.NewLocalizedError("error.fields_mandatory")
+ return locale.NewLocalizedError("error.fields_mandatory")
}
return nil
diff --git a/internal/ui/form/auth.go b/internal/ui/form/auth.go
index 37c3eab0..d1a9055b 100644
--- a/internal/ui/form/auth.go
+++ b/internal/ui/form/auth.go
@@ -7,7 +7,7 @@ import (
"net/http"
"strings"
- "miniflux.app/v2/internal/errors"
+ "miniflux.app/v2/internal/locale"
)
// AuthForm represents the authentication form.
@@ -17,9 +17,9 @@ type AuthForm struct {
}
// Validate makes sure the form values are valid.
-func (a AuthForm) Validate() error {
+func (a AuthForm) Validate() *locale.LocalizedError {
if a.Username == "" || a.Password == "" {
- return errors.NewLocalizedError("error.fields_mandatory")
+ return locale.NewLocalizedError("error.fields_mandatory")
}
return nil
diff --git a/internal/ui/form/settings.go b/internal/ui/form/settings.go
index b640eff7..d5442218 100644
--- a/internal/ui/form/settings.go
+++ b/internal/ui/form/settings.go
@@ -7,7 +7,7 @@ import (
"net/http"
"strconv"
- "miniflux.app/v2/internal/errors"
+ "miniflux.app/v2/internal/locale"
"miniflux.app/v2/internal/model"
)
@@ -64,13 +64,13 @@ func (s *SettingsForm) Merge(user *model.User) *model.User {
}
// Validate makes sure the form values are valid.
-func (s *SettingsForm) Validate() error {
+func (s *SettingsForm) Validate() *locale.LocalizedError {
if s.Username == "" || s.Theme == "" || s.Language == "" || s.Timezone == "" || s.EntryDirection == "" || s.DisplayMode == "" || s.DefaultHomePage == "" {
- return errors.NewLocalizedError("error.settings_mandatory_fields")
+ return locale.NewLocalizedError("error.settings_mandatory_fields")
}
if s.CJKReadingSpeed <= 0 || s.DefaultReadingSpeed <= 0 {
- return errors.NewLocalizedError("error.settings_reading_speed_is_positive")
+ return locale.NewLocalizedError("error.settings_reading_speed_is_positive")
}
if s.Confirmation == "" {
@@ -80,7 +80,7 @@ func (s *SettingsForm) Validate() error {
s.Password = ""
} else if s.Password != "" {
if s.Password != s.Confirmation {
- return errors.NewLocalizedError("error.different_passwords")
+ return locale.NewLocalizedError("error.different_passwords")
}
}
diff --git a/internal/ui/form/subscription.go b/internal/ui/form/subscription.go
index 16dd215b..39e76fd6 100644
--- a/internal/ui/form/subscription.go
+++ b/internal/ui/form/subscription.go
@@ -7,7 +7,7 @@ import (
"net/http"
"strconv"
- "miniflux.app/v2/internal/errors"
+ "miniflux.app/v2/internal/locale"
"miniflux.app/v2/internal/validator"
)
@@ -29,26 +29,26 @@ type SubscriptionForm struct {
UrlRewriteRules string
}
-// Validate makes sure the form values are valid.
-func (s *SubscriptionForm) Validate() error {
+// Validate makes sure the form values locale.are valid.
+func (s *SubscriptionForm) Validate() *locale.LocalizedError {
if s.URL == "" || s.CategoryID == 0 {
- return errors.NewLocalizedError("error.feed_mandatory_fields")
+ return locale.NewLocalizedError("error.feed_mandatory_fields")
}
if !validator.IsValidURL(s.URL) {
- return errors.NewLocalizedError("error.invalid_feed_url")
+ return locale.NewLocalizedError("error.invalid_feed_url")
}
if !validator.IsValidRegex(s.BlocklistRules) {
- return errors.NewLocalizedError("error.feed_invalid_blocklist_rule")
+ return locale.NewLocalizedError("error.feed_invalid_blocklist_rule")
}
if !validator.IsValidRegex(s.KeeplistRules) {
- return errors.NewLocalizedError("error.feed_invalid_keeplist_rule")
+ return locale.NewLocalizedError("error.feed_invalid_keeplist_rule")
}
if !validator.IsValidRegex(s.UrlRewriteRules) {
- return errors.NewLocalizedError("error.feed_invalid_urlrewrite_rule")
+ return locale.NewLocalizedError("error.feed_invalid_urlrewrite_rule")
}
return nil
diff --git a/internal/ui/form/user.go b/internal/ui/form/user.go
index 4c6c4e13..ea4cfcd6 100644
--- a/internal/ui/form/user.go
+++ b/internal/ui/form/user.go
@@ -6,7 +6,7 @@ package form // import "miniflux.app/v2/internal/ui/form"
import (
"net/http"
- "miniflux.app/v2/internal/errors"
+ "miniflux.app/v2/internal/locale"
"miniflux.app/v2/internal/model"
)
@@ -19,31 +19,31 @@ type UserForm struct {
}
// ValidateCreation validates user creation.
-func (u UserForm) ValidateCreation() error {
+func (u UserForm) ValidateCreation() *locale.LocalizedError {
if u.Username == "" || u.Password == "" || u.Confirmation == "" {
- return errors.NewLocalizedError("error.fields_mandatory")
+ return locale.NewLocalizedError("error.fields_mandatory")
}
if u.Password != u.Confirmation {
- return errors.NewLocalizedError("error.different_passwords")
+ return locale.NewLocalizedError("error.different_passwords")
}
return nil
}
// ValidateModification validates user modification.
-func (u UserForm) ValidateModification() error {
+func (u UserForm) ValidateModification() *locale.LocalizedError {
if u.Username == "" {
- return errors.NewLocalizedError("error.user_mandatory_fields")
+ return locale.NewLocalizedError("error.user_mandatory_fields")
}
if u.Password != "" {
if u.Password != u.Confirmation {
- return errors.NewLocalizedError("error.different_passwords")
+ return locale.NewLocalizedError("error.different_passwords")
}
if len(u.Password) < 6 {
- return errors.NewLocalizedError("error.password_min_length")
+ return locale.NewLocalizedError("error.password_min_length")
}
}