Skip to content

Souuup

A robust, type-safe validation library for Go. In any good soup, you need the right ingredients.

Souuup helps you ensure your data has just the right shape and properties, in a type-safe way. It’s a flexible validation framework that lets you easily validate complex data structures with a clear, composable API.

🔍 Type-safe validation

Uses generics for compile-time type checking, ensuring your validation rules match your data types.

🧩 Composable rules

Mix and match validation rules for your specific needs with a clean, functional API.

🌳 Nested validation

Validate complex, nested data structures with hierarchical schemas that mirror your data.

🚦 Detailed error reporting

Get comprehensive error messages with the same shape as your schema for easy debugging.

Here’s a taste of what Souuup looks like:

package main
import (
"fmt"
"github.com/cachesdev/souuup/u"
"github.com/cachesdev/souuup/r"
)
type User struct {
Name string
Age int
Interests []string
}
func main() {
user := User{
Name: "John Smith",
Age: 27,
Interests: []string{"reading", "cycling", "photography"},
}
// Create a validator with the schema
s := u.NewSouuup(u.Schema{
"username": u.Field(user.Name, r.MinS(3), r.MaxS(20)),
"age": u.Field(user.Age, r.MinN(18), r.MaxN(120)),
"interests": u.Field(user.Interests,
r.MinLen[string](1), // At least one interest required
r.Every(r.MinS(3)), // Each interest must be at least 3 characters
),
})
// Validate the data
err := s.Validate()
if err != nil {
fmt.Println("Validation failed:", err)
return
}
fmt.Println("Validation succeeded!")
}

Type Safety First: Built with Go generics, Souuup ensures your validation rules are type-safe at compile time.

Composable Design: Create complex validation logic by combining simple, reusable rules.

Clear Error Messages: When validation fails, you get detailed, structured error messages that tell you exactly what went wrong and where.

Familiar API: If you’ve used validation libraries like Ozzo or Valibot, you’ll feel right at home with Souuup’s API design.

Getting Started

Learn how to install and set up Souuup in your Go project. Get Started →

Basic Usage

Understand the core concepts and create your first validators. Basic Usage →

API Reference

Explore all available validation rules and functions. API Reference →

Examples

See real-world examples and use cases. Examples →