mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Refactor HTTP Client and LocalizedError packages
This commit is contained in:
parent
120aabfbce
commit
14e25ab9fe
104 changed files with 1277 additions and 10672 deletions
|
@ -4,32 +4,11 @@
|
|||
package validator // import "miniflux.app/v2/internal/validator"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
|
||||
"miniflux.app/v2/internal/locale"
|
||||
)
|
||||
|
||||
// ValidationError represents a validation error.
|
||||
type ValidationError struct {
|
||||
TranslationKey string
|
||||
}
|
||||
|
||||
// NewValidationError initializes a validation error.
|
||||
func NewValidationError(translationKey string) *ValidationError {
|
||||
return &ValidationError{TranslationKey: translationKey}
|
||||
}
|
||||
|
||||
func (v *ValidationError) String() string {
|
||||
return locale.NewPrinter("en_US").Printf(v.TranslationKey)
|
||||
}
|
||||
|
||||
func (v *ValidationError) Error() error {
|
||||
return errors.New(v.String())
|
||||
}
|
||||
|
||||
// ValidateRange makes sure the offset/limit values are valid.
|
||||
func ValidateRange(offset, limit int) error {
|
||||
if offset < 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue