npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@titanpl/valid

v1.1.1

Published

titan-valid is a robust validation library built specifically for the Titan ecosystem. It provides a simple, fluent API for validating complex data structures with meaningful error messages. It is pure JavaScript, fast, and dependency-free.

Readme

🪐 Titan Extension: titan-valid

A lightweight, chainable, production-ready validation engine for Titan Planet.

titan-valid is a robust validation library built specifically for the Titan ecosystem. It provides a simple, fluent API for validating complex data structures with meaningful error messages. It is pure JavaScript, fast, and dependency-free.


� Features

  • Chainable API: Easy to read and write rules (e.g., .min(5).max(10).email()).
  • Comprehensive Types: Support for String, Number, Boolean, Object, and Array.
  • Nested Validation: Deep validation for objects and arrays with dot-notation error paths.
  • Zero Dependencies: Lightweight and extremely fast.
  • Titan Native integration: Automatically exposes itself as t.valid.

� Installation

This extension comes pre-packaged or can be installed via npm in your Titan project:

npm install titan-valid

💻 Usage

Once installed, the library is available globally as t.valid within the Titan Runtime.

Basic Examples

String Validation

const schema = t.valid.string()
    .min(3)
    .max(20)
    .email();

try {
    schema.parse("[email protected]"); // returns "[email protected]"
} catch (error) {
    console.log(error.errors); 
    // [{ field: "root", rule: "email", message: "Must be a valid email" }]
}

Object Validation

const userSchema = t.valid.object({
    username: t.valid.string().min(3),
    age: t.valid.number().min(18),
    isAdmin: t.valid.boolean(),
    tags: t.valid.array(t.valid.string()).min(1)
});

try {
    userSchema.parse({
        username: "TitanUser",
        age: 25,
        isAdmin: false,
        tags: ["developer", "extension"]
    });
} catch (e) {
    console.error(e.message);
}
export const register = (req) => {
    // 1. Define Validation Schema
    const schema = t.valid.object({
        username: t.valid.string().min(3).max(30),
        email: t.valid.string().email(),
        password: t.valid.string().min(6)
    });

    try {
        const body = req.body || {};

        // 2. Validate
        schema.parse(body);

        let hashedPassword = t.password.hash(body.password);
        // t.log(hashedPassword)

        t.log("Register", `New user registered: ${body.username}`);

        return {
            success: true,
            message: "User created successfully",
            user: {
                username: body.username,
                email: body.email
            }
        };

    } catch (error) {
        if (error.name === "ValidationError") {
            // t.log(error)
            return { error: error.message };
        } else {
            t.log("Register Error", error.message);
            return { error: "Internal Server Error" };
        }
    }
}

Supported API

t.valid.string()

  • .min(n): Minimum length.
  • .max(n): Maximum length.
  • .length(n): Exact length.
  • .email(): Validates email format.
  • .regex(pattern): Matches a RegExp pattern.

t.valid.number()

  • .min(n): Minimum value.
  • .max(n): Maximum value.

t.valid.array(type)

  • .min(n): Minimum number of items.
  • .max(n): Maximum number of items.
  • .length(n): Exact number of items.

t.valid.object(shape)

  • Validates object structure recursively.

t.valid.optional(type)

  • Allows null or undefined values.

� Project Structure

  • index.js: Main library source code.
  • titan.json: Extension manifest.

🧪 Testing

You can test changes to this extension using the Titan SDK runner:

titan run ext

Visit http://localhost:3000/test to see the validation engine in action.


Happy coding on Titan Planet! 🚀