Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Guardrails ai Guardrails Custom Validator Integration

From Leeroopedia
Knowledge Sources
Domains Validation, Integration
Last Updated 2026-02-14 00:00 GMT

Overview

An integration principle for attaching custom-built validators to a Guard pipeline and configuring their failure behavior and validation targets.

Description

Custom Validator Integration bridges the gap between a standalone custom validator class and a working Guard pipeline. After a validator is implemented and registered, it must be instantiated with its specific parameters and on-fail action, then attached to a Guard targeting the appropriate output scope (full output, specific field, or input messages).

This step transforms a custom validator from a reusable component into an active part of a specific validation pipeline, with its failure behavior and scope configured for the use case.

Usage

After implementing and registering a custom validator, instantiate it with application-specific parameters and an on_fail action. Then attach it to a Guard using .use(), specifying the on target if needed.

Theoretical Basis

Integration follows three configuration decisions:

  1. Parameterization: Instantiate the validator with use-case-specific settings (thresholds, patterns, etc.)
  2. Failure Strategy: Choose the on_fail action: EXCEPTION (strict), FIX (auto-correct), REASK (LLM retry), FILTER (remove), REFRAIN (return None), NOOP (log only)
  3. Target Scope: Choose validation target: "output" (full LLM output), "messages" (input validation), or a JSON path like "$.field" (field-level)

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment