name: guardrails-output-regex-validator description: Validates and enforces structured formatting, PII absence, and regex schema rules using Guardrails AI. Use when preventing malformed or policy-violating agent responses. license: MIT metadata: author: Community List Maintainers version: "1.0.0" source: "https://github.com/guardrails-ai/guardrails"
Guardrails Output Regex Validator
Overview
Guardrails AI provides runtime validation for LLM outputs, verifying structural constraints, checking PII sanitization, and triggering automatic re-asking on validation failure.
Operational Workflow
Define Guard spec specifying expected JSON schema, regex constraints, and PII filters.:
- Define Guard spec specifying expected JSON schema, regex constraints, and PII filters.
Wrap model generation call with Guard object validation wrapper.:
- Wrap model generation call with Guard object validation wrapper.
Execute automatic corrective re-asking prompt if output violates schema constraints.:
- Execute automatic corrective re-asking prompt if output violates schema constraints.
Emit sanitized, verified output or raise structured validation exceptions.:
- Emit sanitized, verified output or raise structured validation exceptions.
Recommended Tools & Environments
- Guardrails AI
- Python 3.10+
- Pydantic
- Regex
Verification & Execution Criteria
- Pre-execution validation verifies all prerequisites and inputs.
- Step-by-step progress logging confirms intermediate state transitions.
- Post-execution checks verify output integrity and clean exit codes.