Skip to main content

ValidAuth

Lightweight, powerful authentication validators for JavaScript applications

Why 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.

Zero Dependencies

Lightweight package with no external dependencies. Keep your bundle size small.

Security-First

Built-in checks for common vulnerabilities and leaked passwords.

Highly Configurable

Customize validation rules to fit your specific requirements.

Framework Agnostic

Works with React, Vue, Angular, vanilla JS, and more.

Quick Example

import { isEmail, isPassword, isUsername } from 'validauth';

// Email validation
if (isEmail('[email protected]')) {
  console.log('Valid email!');
}

// Password validation with custom rules
const result = isPassword('MyP@ssw0rd123', {
  minLength: 10,
  requireSymbols: true,
  forbidCommonPasswords: true,
  details: true
});

if (!result.valid) {
  console.log('Errors:', result.errors);
}

// Username validation
if (isUsername('johndoe')) {
  console.log('Valid username!');
}

Features

Email Validation

Validate email addresses with customizable rules and domain blocking

Password Validation

Check password strength with comprehensive security checks

Username Validation

Validate usernames with reserved name blocking

OTP Validation

Generate and validate one-time passwords

Session Tokens

Create and validate secure session tokens

XSS Protection

Check inputs for cross-site scripting vulnerabilities

Get Started

Installation

Install ValidAuth in your project

Quickstart

Get up and running in minutes

API Reference

Explore the complete API

Community

GitHub

View source code and contribute

npm Package

View the package on npm

Build docs developers (and LLMs) love