Validates string length is within bounds.
Can be used for both input and output validation. Ensures content is neither too short nor too long.
Value parameters
- max
-
Maximum length (inclusive)
- min
-
Minimum length (inclusive)
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait OutputGuardrailtrait InputGuardrailtrait Guardrail[String]class Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Optional: Transform the output after validation. Default is identity (no transformation).
Optional: Transform the output after validation. Default is identity (no transformation).
Value parameters
- output
-
The validated output
Attributes
- Returns
-
The transformed output
- Definition Classes
Inherited methods
Compose this guardrail with another sequentially.
Compose this guardrail with another sequentially.
The second guardrail runs only if this one passes.
Value parameters
- other
-
The guardrail to run after this one
Attributes
- Returns
-
A composite guardrail that runs both in sequence
- Inherited from:
- Guardrail
Validates value inside an agent's hook, as validate(value) does, with the hook's context. A guardrail that calls a model overrides this to call through context.accounted, so the call is counted in the thread's usage and on the run's terminal event even when the task fails (design §4.22); one that combines guardrails passes context on to each. GuardrailMiddleware and GuardrailReviewMiddleware call this form.
Validates value inside an agent's hook, as validate(value) does, with the hook's context. A guardrail that calls a model overrides this to call through context.accounted, so the call is counted in the thread's usage and on the run's terminal event even when the task fails (design §4.22); one that combines guardrails passes context on to each. GuardrailMiddleware and GuardrailReviewMiddleware call this form.
Attributes
- Inherited from:
- Guardrail
Concrete fields
Optional description of what this guardrail validates.
Optional description of what this guardrail validates.
Attributes
Name of this guardrail for logging and error messages.
Name of this guardrail for logging and error messages.