Skip to main content

Overview

The ValidateContent block validates text content against various rules like required substrings, forbidden words, length constraints, and regex patterns.

Input Parameters

Required

ParameterTypeDescription
textstringThe text content to validate
Note: Use the from/as input format to map your data to the text parameter.

Configuration

All config parameters are optional. Use the ones relevant to your validation:
ParameterTypeDescription
containsstring/arrayRequired substring(s) - case insensitive
notContainsstring/arrayForbidden substring(s) - case insensitive
minLengthnumberMinimum text length
maxLengthnumberMaximum text length
matchesstringRegex pattern the text must match
matchFlagsstringRegex flags (default: 'i' for case-insensitive)

Output Fields

FieldTypeDescription
passedbooleanWhether all validations passed
failuresarrayList of validation failures
scorenumberValidation score (0.0 - 1.0)
checksobjectIndividual check results

Examples

Validate Required Keywords

Success:
Failure:

Forbid Inappropriate Content

Validate Text Length

Regex Pattern Matching

Combined Validations

Common Patterns

Validate AI Response Quality

Multi-Field Validation

Content Safety Check

Validation Score

The score field represents how well the content passed validation:
  • 1.0 - All validations passed
  • 0.5 - Some validations failed
  • < 0.5 - Multiple validations failed
The score is calculated based on:
  • Missing required content
  • Forbidden content found
  • Length violations
  • Pattern mismatches
Use the score for assertions:

Error Messages

Common failure messages:
MessageCause
Missing expected content: wordRequired substring not found
Found forbidden content: wordForbidden substring found
Text too short: 5 < 10Below minLength
Text too long: 600 > 500Above maxLength
Text doesn't match pattern: regexRegex pattern didn’t match

Full Example

Tips

ValidateContent expects a text parameter. Use the from/as format:
The contains and notContains checks are case-insensitive:
Use ValidateContent for structural checks, LLMJudge for semantic validation:
Regex patterns are powerful for complex validation:

When to Use

Use ValidateContent when:
  • Checking for required keywords
  • Filtering inappropriate content
  • Validating text length
  • Pattern matching (emails, URLs, etc.)
  • Structural content validation
Use LLMJudge instead when:
  • Checking semantic meaning
  • Evaluating tone or style
  • Comparing similarity to expected content
  • Complex reasoning about content

Next Steps

LLMJudge

Semantic content validation

ValidateTools

Validate AI tool calls