Overview
The ValidateContent block validates text content against various rules like required substrings, forbidden words, length constraints, and regex patterns.Input Parameters
Required
Parameter | Type | Description |
---|---|---|
text | string | The text content to validate |
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:Parameter | Type | Description |
---|---|---|
contains | string/array | Required substring(s) - case insensitive |
notContains | string/array | Forbidden substring(s) - case insensitive |
minLength | number | Minimum text length |
maxLength | number | Maximum text length |
matches | string | Regex pattern the text must match |
matchFlags | string | Regex flags (default: 'i' for case-insensitive) |
Output Fields
Field | Type | Description |
---|---|---|
passed | boolean | Whether all validations passed |
failures | array | List of validation failures |
score | number | Validation score (0.0 - 1.0) |
checks | object | Individual check results |
Examples
Validate Required Keywords
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
Thescore
field represents how well the content passed validation:
- 1.0 - All validations passed
- 0.5 - Some validations failed
- < 0.5 - Multiple validations failed
- Missing required content
- Forbidden content found
- Length violations
- Pattern mismatches
Error Messages
Common failure messages:Message | Cause |
---|---|
Missing expected content: word | Required substring not found |
Found forbidden content: word | Forbidden substring found |
Text too short: 5 < 10 | Below minLength |
Text too long: 600 > 500 | Above maxLength |
Text doesn't match pattern: regex | Regex pattern didn’t match |
Full Example
Tips
Use from/as Input Format
Use from/as Input Format
ValidateContent expects a
text
parameter. Use the from/as format:Case-Insensitive by Default
Case-Insensitive by Default
The
contains
and notContains
checks are case-insensitive:Combine with LLMJudge
Combine with LLMJudge
Use ValidateContent for structural checks, LLMJudge for semantic validation:
Use Regex for Complex Patterns
Use Regex for Complex Patterns
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
- Checking semantic meaning
- Evaluating tone or style
- Comparing similarity to expected content
- Complex reasoning about content