ctrovalidate-core
v1.0.0
Published
Core validation logic for Ctrovalidate (Headless).
Maintainers
Readme
ctrovalidate-core
Zero-dependency, platform-agnostic validation engine for JavaScript and TypeScript.
The headless validation engine at the heart of the Ctrovalidate ecosystem. Provides pure validation logic with zero runtime dependencies — runs in Node.js, browsers, edge functions, and any JavaScript environment.
Installation
npm install ctrovalidate-coreQuick Start
import { validate } from 'ctrovalidate-core';
const results = validate(
{ email: '[email protected]', age: 25 },
{ email: 'required|email', age: 'required|min:18' }
);
// { email: { isValid: true, error: null, rule: null }, age: { ... } }API Overview
| Function | Description |
|----------|-------------|
| validateValue(value, rules, options?) | Validate a single value synchronously |
| validate(data, schema, options?) | Validate an entire data object synchronously |
| validateValueAsync(value, rules, options?) | Validate a single value asynchronously |
| validateAsync(data, schema, options?) | Validate an entire data object asynchronously |
Full documentation: ctrovalidate-core API Reference · Guide
Features
- 22 built-in rules:
required,email,min,max,minLength,maxLength,alpha,alphaNum,alphaDash,alphaSpaces,numeric,integer,decimal,url,ipAddress,json,phone,creditCard,strongPassword,exactLength,between,sameAs - 4 validation functions: Sync and async, single value and full object
- Schema formats: String (
"required|email"), array, or hybrid - Rule aliases: Recursive macro expansion with cycle protection
- i18n: Built-in
Translatorwith locale switching and parameter interpolation - Async support:
AbortSignalintegration for race-condition-free remote validation - Zero dependencies: ~5KB minified
Documentation
- Full API Reference
- Core Concepts Guide
- Rules Catalog
- Schema System
- Custom Rules
- Async Validation
- i18n & Localization
License
MIT © Ctrotech
