Introduction to ValidAuth
ValidAuth is a modern JavaScript library that provides robust validators for authentication forms. Built with security and developer experience in mind, it helps you validate emails, passwords, usernames, and more with just a few lines of code.ValidAuth is framework-agnostic and works seamlessly with React, Vue, Angular, vanilla JavaScript, Node.js, and any other JavaScript environment.
Why ValidAuth?
Authentication validation shouldn’t be complicated. ValidAuth eliminates the complexity of writing regex patterns, manual security checks, and repetitive validation logic.Before ValidAuth
After ValidAuth
Key Features
Zero Dependencies
Completely standalone with no external dependencies. Keep your bundle size minimal.
Lightweight
Only ~14KB minified and ~5KB gzipped. Tree-shakeable to import only what you need.
Security-First
Built-in protection against common passwords, XSS attacks, and security vulnerabilities.
Highly Configurable
Extensive options to customize validation rules for your specific requirements.
Detailed Error Messages
Get comprehensive error feedback to guide users through fixing validation issues.
Framework Agnostic
Works with React, Vue, Angular, Svelte, or vanilla JavaScript - no lock-in.
What Can You Validate?
ValidAuth provides validators for all common authentication scenarios:- Email addresses - RFC-compliant validation with domain blocking, plus addressing, and TLD requirements
- Passwords - Strength checking, common password detection, configurable complexity rules
- Usernames - Length limits, character restrictions, reserved name blocking
- OTP codes - One-time password validation with attempt limiting
- Session tokens - JWT-style token generation and validation
- XSS prevention - Input sanitization to prevent cross-site scripting attacks
How ValidAuth Compares
| Feature | ValidAuth | validator.js | joi | yup |
|---|---|---|---|---|
| Bundle Size | ~14KB | ~100KB | ~150KB | ~80KB |
| Dependencies | 0 | 0 | Many | Many |
| Auth-Focused | ✅ | ❌ | ❌ | ❌ |
| Common Password Check | ✅ | ❌ | ❌ | ❌ |
| Password Strength | ✅ | ❌ | ❌ | ❌ |
| Detailed Errors | ✅ | ⚠️ | ✅ | ✅ |
| Easy to Use | ✅ | ✅ | ⚠️ | ⚠️ |
Design Philosophy
ValidAuth is built on three core principles:- Simplicity - Simple, intuitive API that developers can learn in minutes
- Security - Built-in protection against common vulnerabilities and attack vectors
- Flexibility - Extensive configuration options without sacrificing ease of use
Real-World Use Cases
User Registration Forms
User Registration Forms
Validate email, password, and username simultaneously with customized rules for each field. Block disposable emails, enforce strong passwords, and reserve admin usernames.
Login Authentication
Login Authentication
Accept both email and username as login identifiers with flexible validation that adapts based on input format.
Password Reset Flows
Password Reset Flows
Enforce strong password requirements and prevent users from reusing old passwords or including their username in the new password.
Two-Factor Authentication
Two-Factor Authentication
Validate OTP codes with attempt limiting and expiration tracking to secure your 2FA implementation.
Social Media Platforms
Social Media Platforms
Browser and Environment Support
ValidAuth works everywhere JavaScript runs:- ✅ Browsers: Chrome, Firefox, Safari, Edge (latest versions)
- ✅ Node.js: Version 12 and above
- ✅ Server-side: Express, Fastify, Koa, Next.js API routes
- ✅ Frontend: React, Vue, Angular, Svelte, vanilla JS
- ✅ Mobile: React Native, Ionic, Capacitor
Next Steps
Installation
Install ValidAuth and set up your project in under a minute
Quick Start
Get started with practical examples and common use cases