Documentation
¶
Overview ¶
Package validate provides composable validation helpers for Go with fluent builders, rule tags, and struct validation. It includes optional message translation support.
Index ¶
- Constants
- Variables
- func FromTag(v *Validate, tag string) (func(any) error, error)
- func ValidateStruct(v *Validate, s any) error
- type BoolBuilder
- type CustomTypeBuilder
- type Errors
- type IntBuilder
- type Kind
- type Rule
- type SimpleTranslator
- type SliceBuilder
- type StringBuilder
- type Translator
- type Validate
- type ValidatorFunc
Constants ¶
const ( // String validation kinds KString = types.KString KLength = types.KLength KMinLength = types.KMinLength KMaxLength = types.KMaxLength KRegex = types.KRegex KOneOf = types.KOneOf KMinRunes = types.KMinRunes KMaxRunes = types.KMaxRunes // Generic modifiers KOmitempty = types.KOmitempty // Integer validation kinds KInt = types.KInt KInt64 = types.KInt64 KMinInt = types.KMinInt KMaxInt = types.KMaxInt // Slice validation kinds KSlice = types.KSlice KSliceLength = types.KSliceLength KMinSliceLength = types.KMinSliceLength KMaxSliceLength = types.KMaxSliceLength KForEach = types.KForEach // Boolean validation kinds KBool = types.KBool )
Re-export commonly used rule kinds
Variables ¶
var ( NewSimpleTranslator = translator.NewSimpleTranslator DefaultEnglishTranslations = translator.DefaultEnglishTranslations )
Re-export translator functions
var (
NewRule = types.NewRule
)
Re-export types functions
Functions ¶
func ValidateStruct ¶ added in v3.0.3
ValidateStruct validates a struct using v (or a fresh instance).
Types ¶
type BoolBuilder ¶
type BoolBuilder = glue.BoolBuilder
type CustomTypeBuilder ¶ added in v3.0.3
type CustomTypeBuilder = glue.CustomTypeBuilder
type IntBuilder ¶
type IntBuilder = glue.IntBuilder
type SimpleTranslator ¶ added in v3.0.4
type SimpleTranslator = translator.SimpleTranslator
type SliceBuilder ¶
type SliceBuilder = glue.SliceBuilder
type StringBuilder ¶
type StringBuilder = glue.StringBuilder
type Translator ¶ added in v3.0.4
type Translator = translator.Translator
Re-export translator package
type Validate ¶
Re-export types for a developer-friendly root facade.
func New ¶
func New() *Validate
New returns a Validate configured with sensible defaults.
Defaults: - Installs default English translations via SimpleTranslator. - Registers built-in plugins (email, ulid, uuid) via blank imports.
func NewBare ¶
func NewBare() *Validate
NewBare returns a Validate without installing a default translator. Useful for advanced setups that manage translations differently.
func NewWithTranslator ¶
func NewWithTranslator(tr translator.Translator) *Validate
NewWithTranslator returns a Validate configured with the provided translator while keeping other defaults.
type ValidatorFunc ¶ added in v3.0.4
type ValidatorFunc = types.ValidatorFunc
Directories
¶
| Path | Synopsis |
|---|---|
|
Package core provides the main validation engine and fluent builder APIs.
|
Package core provides the main validation engine and fluent builder APIs. |
|
Package errors provides error types and error handling utilities for validation.
|
Package errors provides error types and error handling utilities for validation. |
|
Package examples provides examples for the validate package.
|
Package examples provides examples for the validate package. |
|
Package structvalidator provides struct validation functionality using reflection.
|
Package structvalidator provides struct validation functionality using reflection. |
|
Package translator provides internationalization support for validation messages.
|
Package translator provides internationalization support for validation messages. |
|
Package types provides the core validation engine types and rule system.
|
Package types provides the core validation engine types and rule system. |
|
Package validators provides built-in validation rules and plugin architecture.
|
Package validators provides built-in validation rules and plugin architecture. |
|
email
Package email provides email address validation as a plugin.
|
Package email provides email address validation as a plugin. |
|
ulid
Package ulid provides ULID validation as a plugin.
|
Package ulid provides ULID validation as a plugin. |
|
uuid
Package uuid provides UUID validation as a plugin.
|
Package uuid provides UUID validation as a plugin. |