validation

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package validation provides custom validation rules for the application.

Index

Constants

This section is empty.

Variables

View Source
var Email = validation.NewStringRuleWithError(
	func(s string) bool {
		return emailRegex.MatchString(s)
	},
	validation.NewError("validation_email_format", "must be a valid email address"),
)

Email validates email format using regex

View Source
var NoWhitespace = validation.NewStringRuleWithError(
	func(s string) bool {
		return s == strings.TrimSpace(s)
	},
	validation.NewError("validation_no_whitespace", "must not contain leading or trailing whitespace"),
)

NoWhitespace validates that string doesn't contain leading/trailing whitespace

View Source
var NotBlank = validation.NewStringRuleWithError(
	func(s string) bool {
		return strings.TrimSpace(s) != ""
	},
	validation.NewError("validation_not_blank", "must not be blank"),
)

NotBlank validates that a string is not empty after trimming whitespace

Functions

func WrapValidationError

func WrapValidationError(err error) error

WrapValidationError wraps validation errors as domain ErrInvalidInput

Types

type PasswordStrength

type PasswordStrength struct {
	MinLength      int
	RequireUpper   bool
	RequireLower   bool
	RequireNumber  bool
	RequireSpecial bool
}

PasswordStrength validates password meets minimum security requirements

func (PasswordStrength) Validate

func (p PasswordStrength) Validate(value interface{}) error

Validate checks if the password meets the configured requirements

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL