Skip to content

ziganticPydantic-like validation for Zig

Type-safe data validation with 40+ built-in types, human-readable errors, and zero runtime overhead. 102 tests passing.

zigantic

🚀 Quick Example

zig
const std = @import("std");
const z = @import("zigantic");

pub fn main() !void {
    // Direct validation with rich utilities
    const email = try z.Email.init("alice@company.com");
    std.debug.print("Domain: {s}\n", .{email.domain()});           // "company.com"
    std.debug.print("Business: {}\n", .{email.isBusinessEmail()}); // true

    // Password with strength checking
    const pwd = try z.Secret(8, 100).init("MyP@ss123!");
    std.debug.print("Strength: {d}/6\n", .{pwd.strength()}); // 5

    // Numbers with utilities
    const age = try z.Int(i32, 18, 120).init(25);
    std.debug.print("Even: {}, Positive: {}\n", .{age.isEven(), age.isPositive()});

    // IP with network utilities
    const ip = try z.Ipv4.init("192.168.1.1");
    std.debug.print("Private: {}\n", .{ip.isPrivate()}); // true
}

📦 Installation

bash
zig fetch --save https://github.com/muhammad-fiaz/zigantic/archive/refs/tags/v0.0.1.tar.gz
zig
// build.zig
const zigantic = b.dependency("zigantic", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("zigantic", zigantic.module("zigantic"));

📚 Type Categories

String Types (9)

String NonEmptyString Trimmed Lowercase Uppercase Alphanumeric AsciiString Secret StrongPassword

Number Types (14)

Int UInt PositiveInt NonNegativeInt NegativeInt EvenInt OddInt MultipleOf Float Percentage Probability PositiveFloat NegativeFloat FiniteFloat

Format Types (11)

Email Url HttpsUrl Uuid Ipv4 Ipv6 Slug Semver PhoneNumber CreditCard Regex

Collection Types (3)

List NonEmptyList FixedList

Special Types (10)

Default Custom Transform Coerce Literal Partial OneOf Range Nullable Lazy

🏃 Examples

Run the included examples:

bash
zig build run-basic           # Direct validation + JSON
zig build run-advanced_types  # All 40+ types demo
zig build run-validators      # Validator functions
zig build run-json_example    # Full JSON workflow
zig build run-error_handling  # Error management

❤️ Made with love for the Zig community

Released under the MIT License.