Building 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