Building Custom Transformers
Learn how to build custom transformers to process and shape data in BoxLang AI pipelines.
🎯 Why Custom Transformers?
🏗️ Transformer Architecture
📝 ITransformer Interface
interface {
/**
* Transform input data
* @param input The data to transform
* @return Transformed data
*/
public any function transform( required any input );
/**
* Configure the transformer
* @param config Configuration struct
* @return this (for fluent API)
*/
public any function configure( required struct config );
}🚀 Quick Start: Simple Transformer
🎨 Using Transformers in Pipelines
Inline Transformers
Named Transformers with aiTransform()
Custom Transformer Classes
💡 Advanced Example: JSON Schema Validator
🔄 Extending BaseTransformer
Core Methods
Chainable Configuration
🎯 Built-In Transformers
TextChunker
TextCleaner
AiTransformRunnable
💼 Real-World Examples
Code Extractor
Price Parser
Sentiment Analyzer
✅ Best Practices
1. Handle Multiple Input Types
2. Validate and Sanitize
3. Provide Meaningful Errors
4. Make Transformers Reusable
📚 Next Steps
🎓 Summary
Last updated