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

@mehmetefekaskaya/smart-validator

v1.0.1

Published

A powerful, flexible, and framework-agnostic validation library for forms.

Readme

🧩 Overview

smart-validator is a minimalist yet powerful validation library for JavaScript and TypeScript.
It combines functional rule-based validation with optional schema validation (Zod/Yup/Joi),
making it ideal for both client-side forms and backend data validation.


📘 Table of Contents


🚀 Features

✅ Simple rule-based syntax (required(), minLength(6), etc.)
✅ Nested & flat form validation (validateForm, validateNestedForm)
✅ Supports Zod, Yup, and Joi schemas
✅ Custom translations and localization
✅ Async validation with debounce and error resilience
✅ Conditional validation (requiredIf)
✅ Rule composition (combineRules)
✅ React-ready <RenderErrors /> component
✅ TypeScript-first – fully typed error objects


📦 Installation

npm install @mehmetefekaskaya/smart-validator Documentation: https://www.npmjs.com/package/@mehmetefekaskaya/smart-validator

or

yarn add @mehmetefekaskaya/smart-validator


🌍 Built-in Utility Functions

| Function | Description | | ---------------------------------- | -------------------------------------------------- | | cleanErrorsDeep(errors) | Removes null and empty error entries recursively | | mergeErrors(a, b) | Merges multiple validation result objects | | getNestedError(errors, path) | Retrieves nested field errors safely | | checkExtraFields(values, rules) | Detects undefined fields | | findMissingFields(values, rules) | Validates schema completeness |


🧩 Supported Functions

| Function | Type | Description | | ---------------------------------- | ----- | --------------------------------- | | validateForm() | Sync | Flat object validation | | validateNestedForm() | Sync | Deep object validation | | validateFormAsync() | Async | Async rules (e.g., API checks) | | validateNestedFormAsync() | Async | Async + nested support | | validateWithSchema() | Async | Works with Zod, Yup, Joi | | validateFormFunctionWithSchema() | Async | Combines rule + schema validation |


🧠 Writing Custom Rules

import { getMessage, setCustomTranslations } from "smart-validator";

setCustomTranslations("en", {
  startsWith: "Must start with '{prefix}'",
});

// 2️⃣ Define your custom rule
export function startsWith(prefix: string): SyncValidationRule {
  return (value: string, language?: string) =>
    !value.startsWith(prefix)
      ? getMessage("startsWith", { prefix }, language)
      : null;
}

📚 Examples

All examples are available inside the /examples folder.

Each file demonstrates a specific capability of smart-validator:
| Example File | Description |
| ----------------------------------------- | -------------------------------------------------------- |
| `ValidateFormExample.tsx` | Basic synchronous form validation |
| `ValidateNestedFormExample.tsx` | Deep / nested object validation |
| `ValidateAsyncFormExample.tsx` | Async field validation (e.g., API checks) |
| `ValidateAsyncBatchFormExample.tsx` | Async batch field validation |
| `ValidateAsyncNestedFormExample.tsx` | Async + nested validation |
| `ValidateAsyncBatchNestedFormExample.tsx` | Async + nested + batch validation |
| `ValidateCustomMessagesExample.tsx` | Per-field custom error messages |
| `ValidateLocalizationExample.tsx` | Localization & translated messages |
| `ValidateConditionalRulesExample.tsx` | Conditional logic via `requiredIf` |
| `ValidationComposedRulesExample.tsx` | Rule composition via `combineRules` |
| `ValidateCombinedSchemaRulesExample.tsx` | Hybrid validation (rules + schema) |
| `ValidateWithSchemaZod.tsx` | Full schema-only validation using Zod |
| `ValidateOnExample.tsx` | Field-level validation triggers (`onChange`, `onSubmit`) |
| `AsyncDebounceExample.tsx` | Async debounce validation example |

🧩 React Hook Integration (planned)

const { values, errors, handleChange, handleSubmit } = useValidation(rules);


🧭 Versioning & Contributing

smart-validator follows Semantic Versioning (SemVer) ensuring predictable and backward-compatible releases.

We welcome issues, feature requests, and pull requests on GitHub: 👉 github.com/mefekaskaya/smart-validator

Before contributing:

Run npm run build to ensure your code compiles cleanly

Follow the existing coding style (TypeScript, consistent naming)

Keep all new features covered with clear examples under /examples

Your contributions help keep the package small, readable, and truly smart. 💡


🚀 Release Checklist

Before publishing a new version of smart-validator to npm:

Build the package

npm run build

✅ Ensures Rollup output is clean (dist/ folder generated).

Test all examples

Open /examples in your React test app.

Verify validation, localization, async, and schema cases.

Update version

npm version patch # for bug fixes npm version minor # for new features (non-breaking) npm version major # for breaking changes

Publish to npm

npm publish --access public

Tag the release on GitHub

git push origin main --tags

Update README badges if version or bundle size changed.


⚖️ License

MIT © 2025 Mehmet Efe Kaşkaya GitHub: @mefekaskaya