Search for a command to run...
Last updated June 9, 2026
The Ctrovalidate constructor accepts an optional configuration object to customize behavior.
import { Ctrovalidate } from 'ctrovalidate-browser';
import { LogLevel } from 'ctrovalidate-core';
const validator = new Ctrovalidate(document.querySelector('form'), {
realTime: true,
logLevel: LogLevel.WARN,
errorClass: 'field-invalid',
errorMessageClass: 'error-container',
pendingClass: 'validating-state'
});realTimebooleantrueblur and input listeners to tracked fields.logLevelnumber | LogLevel (Enum)LogLevel.NONE (0)LogLevel.NONE (0): No output.LogLevel.ERROR (1): Critical failures.LogLevel.WARN (2): Rule warnings and configuration issues.LogLevel.INFO (3): Lifecycle steps and discovery logs.LogLevel.DEBUG (4): Full internal state transitions.errorClassstring'is-invalid'aria-invalid="true" is also applied automatically.errorMessageClassstring'error-message'pendingClassstring'ctrovalidate-pending'schemaValidationSchemadata-ctrovalidate-rules attributes — a field discovered via both sources gets the combined rules.aliasesRecord<string, SchemaRule>interface CtrovalidateOptions {
logLevel?: number; // Default: 0
errorClass?: string; // Default: 'is-invalid'
errorMessageClass?: string; // Default: 'error-message'
pendingClass?: string; // Default: 'ctrovalidate-pending'
realTime?: boolean; // Default: true
schema?: ValidationSchema; // Programmatic rules
aliases?: Record<string, SchemaRule>; // Instance-level aliases
}