validation

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package validation provides custom validation rules for the application.

Package validation provides custom validation rules for the application.

Index

Constants

This section is empty.

Variables

View Source
var Base64 = validation.By(func(value interface{}) error {
	s, ok := value.(string)
	if !ok {
		return validation.NewError("validation_base64_type", "must be a string")
	}
	if s == "" {
		return nil
	}
	_, err := base64.StdEncoding.DecodeString(s)
	if err != nil {
		return validation.NewError("validation_base64", "must be valid base64-encoded data")
	}
	return nil
})

Base64 validates that a string is valid base64-encoded data.

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

This section is empty.

Jump to

Keyboard shortcuts

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