Skip to content

Static Methods

Static methods and properties are accessed directly on the Ctrovalidate class. They control global behavior across all instances.


Ctrovalidate.addRule()

Register a standard synchronous rule.

  • Signature: (name: string, logic: Function, message: string) => void
  • Logic Signature: (value, params, field) => boolean

Ctrovalidate.addAsyncRule()

Register an asynchronous rule.

  • Signature: (name: string, logic: Function, message: string) => void
  • Logic Signature: (value, params, field, signal) => Promise<boolean>

Ctrovalidate.LogLevel

The logging configuration enum.

LevelValueDescription
NONE0Silent mode. Recommended for production.
ERROR1Log only critical library failures.
WARN2Log configuration issues (e.g. missing error containers).
INFO3Log initialization and field registration.
DEBUG4Verbose output of every rule execution and event.

Usage:

javascript
const validator = new Ctrovalidate(form, {
  logLevel: Ctrovalidate.LogLevel.DEBUG,
});

Next Steps

Released under the MIT License.