How do I transform ErrorBuilder output?
This blog post describes how to transform an output from ErrorBuilder instance.

- Documentation for
ErrorBuilder.addTransform() - create a definition file e.g.
/definitions/transformations.js
ErrorBuilder.addTransform('toObject', function(isResponse) {
var builder = {};
for (var i = 0, length = this.items.length; i < length; i++) {
var err = this.items[i];
// err.name
// err.error
// err.path
// err.index
builder[err.name] = err.error;
}
// HTTP status (if the schema is used in the routing)
this.status = 400;
// Returns a new transformed object
return isResponse ? JSON.stringify(builder) : builder;
});
// Sets the new transformation as a default output for all ErrorBuilders
ErrorBuilder.setDefaultTransform('toObject');Tests:
var err = new ErrorBuilder();
err.push('email', 'Email is not valid');
err.push('age', 'You are too young');
err.push('something'); // error message will be read from a resource filfe
console.log(err.output());
// { email: 'Email is not valid', age: 'You are too young' }Can I create multiple transformations?
Yes. You can create unlimited count of transformations.
ErrorBuilder.addTransform('csv', function() {
// ...
});
ErrorBuilder.addTransform('xml', function() {
// ...
});Usage:
var err = new ErrorBuilder();
err.push('email', 'Email is not valid');
err.push('age', 'You are too young');
err.setTransform('xml');
// OR
var err = new ErrorBuilder();
err.push('email', 'Email is not valid');
err.push('age', 'You are too young');
err.setTransform('csv');Keep reading
Using AI for Traffic Analysis and Smart Parking Monitoring
Discover how AI, NVIDIA Jetson AGX, and Total.js IoT transform camera data into traffic insights and automated parking occupancy monitoring.
Total.js Platform and NVIDIA DeepStream: Automated AI Video Anonymization
Discover how we combined Total.js Platform, Total.js Flow, and NVIDIA DeepStream to build a scalable, GPU-accelerated video anonymization system for a major enterprise customer. Explore how we process large volumes of video recordings, automate workflows across multiple locations, and manage AI-powered anonymization through a centralized interface.
October report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.
Node.js Security Vulnerabilities
Recent Node.js security updates have addressed serious vulnerabilities, including an issue in Brotli decompression. The news is particularly interesting because AI-assisted security research helped uncover a flaw in technology used by applications around the world.
September report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.
August report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.
How to write better Total.js Applications using AI?
Learn how to make AI coding agents write better, more native Total.js applications!
July report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.
Total.js AIModel: a practical foundation for AI-powered workflows
How Total.js helps developers integrate AI models into real applications with routing, actions, streaming, tools, validation, and business logic in one coherent stack.
June report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.