Skip to content

CtrovalidateDeclarative Form Validation

Lightweight, accessible, and zero-dependency. TypeScript-native with 98% test coverage. Define rules in HTML, handle the rest in JS.

Ctrovalidate Logo

Declarative. Reliable. Accessible. โ€‹

Define validation rules in HTML attributes. Ctrovalidate handles the validation logic, error display, and accessibility.

html
<!-- Define rules directly in HTML -->
<div class="form-group">
  <input 
    type="email" 
    name="user_email"
    data-ctrovalidate-rules="required|email"
  />
  <div class="error-message"></div>
</div>
javascript
import { Ctrovalidate } from 'ctrovalidate';

// Initialize with configuration options
const validator = new Ctrovalidate(
  document.querySelector('form'), 
  { realTime: true }
);

// Validate programmatically
const isValid = await validator.validate();

v3.0.0 Highlights โ€‹

21
Built-in Rules
Common, format, and numeric validation
9
API Methods
Complete programmatic control
<5KB
Bundle Size
Gzipped, zero dependencies
98%
Test Coverage
Production-ready reliability

Framework Integration โ€‹

Ctrovalidate works with any JavaScript framework or vanilla JS.

FrameworkStatusDemoDocumentation
Vanilla JSโœ…View DemoGuide
React 18+โœ…View DemoIntegration
Next.js 15+โœ…View DemoIntegration
Vue 3โœ…View DemoIntegration
Alpine.jsโœ…View DemoIntegration
Svelteโœ…-Integration
HTMXโœ…-Best Practices

Styling: Works with Tailwind CSS, CSS Modules, Vanilla CSS, Bootstrap, or any CSS framework.

Get Started โ€‹

Install via npm and start validating forms in minutes.

bash
npm install ctrovalidate

Read the Documentation ยท View API Reference ยท See Examples

Released under the MIT License.