Changelog
All notable changes to Pedantigo are documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[0.1.0] - 2024-12-18
Added
Core Validation
- Struct tag-based validation with
pedantigo:"..."tags - 100+ built-in validation constraints
- Detailed error messages with field paths
- Support for nested structs and slices
Simple API (Recommended)
Unmarshal[T]()- Parse JSON and validate in one callNewModel[T]()- Create validated instances from JSON, maps, or structsValidate[T]()- Validate existing struct instancesSchema[T]()- Get cached JSON SchemaSchemaJSON[T]()- Get JSON Schema as bytesMarshal[T]()- Validate and marshal to JSONDict[T]()- Convert struct to map
Validator API (Advanced)
New[T]()- Create validator with custom optionsValidatorOptions- Configure strict mode, extra fields handlingMarshalOptions- Context-based field exclusion
JSON Schema Generation
- Automatic schema generation from struct tags
- Built-in caching (240x speedup after first call)
- OpenAPI-compatible schema generation
- Thread-safe concurrent access
Streaming Validation
NewStreamParser[T]()- Parse partial JSON from streams- Real-time validation for LLM responses
- Automatic JSON repair for incomplete data
Discriminated Unions
NewUnion[T]()- Type-safe union handling- Multiple discriminator field support
- Automatic variant detection
Cross-Field Validation
eqfield,nefield- Field equality comparisonsltfield,lefield,gtfield,gefield- Field numeric comparisonsrequired_if,required_unless- Conditional requirementsValidatableinterface for custom cross-field logic
Advanced Features
SecretStr/SecretBytes- Safe handling of sensitive dataRegisterValidation()- Custom field validatorsRegisterStructValidation[T]()- Custom struct validators- Context-based field exclusion for marshaling
String Constraints
required,email,url,uuid,alpha,alphanumeric,numericminLength,maxLength,startswith,endswith,containspattern(regex),lowercase,uppercase,asciibase64,hexadecimal,json,jwt,semver
Numeric Constraints
min,max,gt,gte,lt,ltepositive,negative,nonnegative,nonpositivemultipleOf,divisibleBy
Format Constraints
datetime,date,time,durationipv4,ipv6,cidr,maclatitude,longitudeisbn,isbn10,isbn13credit_card,ssncountry_code,currency_code,postal_code
Collection Constraints
minItems,maxItems,uniquedive- Validate slice/array elementskeys,values- Validate map keys/values
[Unreleased]
Performance
- sync.Pool for validation contexts - Reduced allocations during validation by reusing context buffers
- Field constraint caching - Constraints are now built once at validator creation time, not on each validation call
- Cross-field constraint optimization - Merged into cached field structure for faster lookups
Fixed
- Collection element validation -
divetag is now required to validate struct fields inside slices/maps (matches go-playground/validator behavior) - Empty ValidationError message - Now returns "no errors found" instead of confusing "validation failed"
Changed
- Removed unused internal validation package (internal cleanup, no API changes)
Planned
- Additional format validators
- Extended OpenAPI support