Documentation
¶
Overview ¶
Package validation provides form validation for GoSPA projects. Uses Valibot on the client-side (~1.5KB gzipped) and Go validator on server-side.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// SchemasDir is where validation schemas are stored.
SchemasDir string `yaml:"schemas_dir" json:"schemasDir"`
// OutputDir is where generated validation code is written.
OutputDir string `yaml:"output_dir" json:"outputDir"`
// GenerateTypes generates TypeScript types from schemas.
GenerateTypes bool `yaml:"generate_types" json:"generateTypes"`
// GenerateServer generates Go server-side validation.
GenerateServer bool `yaml:"generate_server" json:"generateServer"`
// GenerateClient generates Valibot client-side validation.
GenerateClient bool `yaml:"generate_client" json:"generateClient"`
// StrictMode enables strict validation (no unknown fields).
StrictMode bool `yaml:"strict_mode" json:"strictMode"`
// CustomValidators is a list of custom validator names.
CustomValidators []string `yaml:"custom_validators" json:"customValidators"`
}
Config holds validation plugin configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default validation configuration.
type FieldSchema ¶
type FieldSchema struct {
Type string `json:"type"` // string, number, boolean, date, email, url, uuid, etc.
Required bool `json:"required"` // whether field is required
Min any `json:"min"` // minimum value (number) or length (string)
Max any `json:"max"` // maximum value (number) or length (string)
Pattern string `json:"pattern"` // regex pattern for strings
Message string `json:"message"` // custom error message
Default any `json:"default"` // default value
}
FieldSchema represents a field in a validation schema.
type Plugin ¶ added in v0.1.23
type Plugin struct {
// contains filtered or unexported fields
}
Plugin provides form validation capabilities.
func (*Plugin) Dependencies ¶ added in v0.1.23
func (p *Plugin) Dependencies() []plugin.Dependency
Dependencies returns required dependencies.
type Schema ¶
type Schema struct {
Name string `json:"name"`
Fields map[string]FieldSchema `json:"fields"`
}
Schema represents a validation schema definition.
Click to show internal directories.
Click to hide internal directories.