// Stay in touch?
Products
Encore CloudEncore Cloud
Encore.tsEncore.ts
Encore.goEncore.go
PricingPricing
Book a DemoBook a Demo
Use Cases
AI-Powered DevelopmentAI-Powered Development
Event-Driven SystemsEvent-Driven Systems
Distributed SystemsDistributed Systems
Case StudiesCase Studies
ShowcaseShowcase
Resources
DocsDocs
InstallInstall
Example AppsExample Apps
Demo videoDemo video
ArticlesArticles
ResourcesResources
GitHub ReleasesGitHub Releases
Systems Operational
Company
About UsAbout Us
Swag ShopSwag Shop
ContactContact
JobsJobs
PressPress
TermsTerms
Privacy PolicyPrivacy Policy
Data Processing AgreementData Processing Agreement
Enterprise SLAEnterprise SLA
Encore
© 2026 EncoreAll rights reserved
© 2026 Encore All Rights Reserved
GitHubDiscordYouTube

Advanced Validation in Encore.ts

Launch Week Day 4

Dec 12, 2024
3 Min Read
Marcus Kohlberg
Dec 12, 2024

Advanced Validation in Encore.ts

Launch Week Day 4

Marcus Kohlberg
3 Min Read

It's Day 4 of Launch Week and we're back with another launch...

Encore.ts now supports value-based validation

Today, we’re excited to announce advanced value-based validation support for Encore.ts. Here’s everything you need to know about this game-changing feature and how it works.

Value-Based Validation: Type-Safe, Fast, and Flexible

Encore.ts has always made defining request and response types intuitive with ordinary TypeScript types. By leveraging these types, Encore ensures both compile-time and runtime type safety. If a request doesn’t conform to the specified type, Encore automatically responds with a 400 error, keeping your API robust. Within the API handler, you also benefit from full type-safety for the params object.

But beyond ensuring all the expected fields are present with the right types, it's also important to be able to validate that the values are within acceptable ranges, or match specific patterns.

We're excited to announce that Encore.ts now has support for value-based validation!

Like the rest of Encore, this new functionality makes direct of use the TypeScript type system to define the validation rules.

Here's what it looks like:

import { Min, Max, MinLen, MaxLen, IsEmail, IsURL } from "encore.dev/validate"; export interface Params { // A number between 3 and 1000 (inclusive). foo: number & (Min<3> & Max<1000>); // A string between 5 and 20 characters long. bar: string & (MinLen<5> & MaxLen<20>); // A string that is either a URL or an email address. urlOrEmail: string & (IsURL | IsEmail); // An array of up to 10 email addresses. emails: Array<string & IsEmail> & MaxLen<10>; }

As you can see, it's easy to add value-based validation rules to any field. You can combine validation rules using & and | (for 'and'/'or').

The full list of validation rules available in Encore.ts includes:

  • Min/Max: validating minimum/maximum values for numbers
  • MinLen/MaxLen: validating minimum/maximum lengths for strings and arrays
  • IsURL/IsEmail: validating that a string is a URL or email address
  • StartsWith/EndsWith/MatchesRegexp: validating that a string matches a specific pattern

Learn more in the documentation.

Rust-Powered Performance

Encore.ts achieves exceptional performance by running validations in Rust, rather than in JavaScript. This is made possible by the fact that Encore.ts uses static analysis of the TypeScript type system to pre-compile what validation rules apply to each field.

This approach outpaces validation frameworks like Zod and TypeBox, providing speed without sacrificing usability, and enables Encore.ts to be 9x faster than Express.js and 3x faster than Elysia and Hono.

See our benchmarks to learn more

Requests/sec

Without validation
With schema validation
121,005
107,018
Encore
v1.38.7
101,611
33,772
Bun (+ Zod)
v1.1.12 / v3.23.8
82,617
35,124
Elysia (+ TypeBox)
v1.1.16 / v0.33.12
71,202
33,150
Hono (+ TypeBox)
v4.6.3 / v0.33.12
62,207
48,397
Fastify (+ Ajv)
v4.27.0 / v8.16.0
15,707
11,878
Express (+ Zod)
v4.19.2 / v3.23.8

Try it yourself

If you're already using Encore, update using encore version update.

If you're new to Encore, install using the instructions below and then create an example app using encore app create.

macOS
Windows
Linux
Brew
$ brew install encoredev/tap/encore

If you have questions or just want to hang out with other Encore developers, join our community on Discord.

Contents
Encore.ts now supports value-based validation
Value-Based Validation: Type-Safe, Fast, and Flexible
Rust-Powered Performance
Try it yourself
Encore

The backend platform for humans and agents

Build backends in Go or TypeScript and run them on your own AWS or GCP, with the guardrails your team and AI agents need to ship safely.

Encore

This blog is presented by Encore, the backend framework for building robust type-safe distributed systems with declarative infrastructure.

Like this article?
Get future ones straight to your mailbox.

You can unsubscribe at any time.

Related Articles

Infrastructure
06/10/26 / 7 Min Read
Infrastructure
06/10/26 / 7 Min Read
Why infrastructure changes still take a week
Application code ships in hours and the infrastructure it needs waits days for review. Where the queue comes from, what AI coding tools did to it, and how teams remove it.
Ivan Cernja
AI
06/03/26 / 7 Min Read
AI
06/03/26 / 7 Min Read
AI agents love type errors
An agent only fixes what it can see before it stops, and a compile error is the one signal that always lands in time.
Ivan Cernja
AI
05/20/26 / 14 Min Read
AI
05/20/26 / 14 Min Read
Are TypeScript backend frameworks ready for AI agents?
We set out to run one benchmark across five TypeScript backend frameworks. Reading the diffs sent us into two more runs, and the picture changed each time.
Ivan Cernja