CompositeGuardrail

org.llm4s.agent.guardrails.CompositeGuardrail
See theCompositeGuardrail companion object
class CompositeGuardrail[A](guardrails: Seq[Guardrail[A]], mode: ValidationMode) extends Guardrail[A]

Combines multiple guardrails with configurable validation mode.

Supports three modes:

  • All: All guardrails must pass (strictest)
  • Any: At least one guardrail must pass (OR logic)
  • First: First result wins (performance optimization)

Type parameters

A

The type of value to validate

Value parameters

guardrails

The guardrails to combine

mode

How to combine validation results

Attributes

Companion
object
Graph
Supertypes
trait Guardrail[A]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def validate(value: A): Result[A]

Validate a value.

Validate a value.

This is a PURE FUNCTION - no side effects allowed. Same input always produces same output.

Value parameters

value

The value to validate

Attributes

Returns

Right(value) if valid, Left(error) if invalid

Inherited methods

def andThen(other: Guardrail[A]): Guardrail[A]

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

Concrete fields

override val description: Option[String]

Optional description of what this guardrail validates.

Optional description of what this guardrail validates.

Attributes

val name: String

Name of this guardrail for logging and error messages.

Name of this guardrail for logging and error messages.

Attributes