Encore

Stay in touch

Product updates and engineering deep-dives.

DiscordGitHubYouTube

© 2026 Encore

Product
Encore PlatformEncore Platform
Encore.tsEncore.ts
Encore.goEncore.go
InstallInstall
PricingPricing
Customers
Case StudiesCase Studies
ShowcaseShowcase
Book a DemoBook a Demo
Resources
DocsDocs
Example AppsExample Apps
Demo videoDemo video
ArticlesArticles
GitHub ReleasesGitHub Releases
Systems Operational
Company
AboutAbout
Swag ShopSwag Shop
ContactContact
JobsJobs
PressPress
SecuritySecurity
Legal
TermsTerms
Privacy PolicyPrivacy Policy
Data Processing AgreementData Processing Agreement
Enterprise SLAEnterprise SLA
← All articles

Advanced Validation in Encore.ts

Launch Week Day 4

Dec 12, 2024
3 Min Read
Marcus Kohlberg
← All articles
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

Automated infrastructure for humans and agents

Let agents build and validate features with real infrastructure in the dev loop. Encore automatically provisions infrastructure, from local dev to production in your cloud on AWS/GCP.

Get started
Encore

This blog is presented by Encore, automated infrastructure for humans and agents. Let agents build and validate features with real infrastructure in the dev loop, from local dev to production in your cloud on AWS/GCP.

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

You can unsubscribe at any time.

Related Articles

Development
07/28/26 / 5 Min Read
Development
07/28/26 / 5 Min Read
Your SQS consumer can hang forever by default
The AWS Rust SDK ships no request timeout by default, so one SQS receive on a dead connection can hang a whole consumer with nothing in the logs.
Ivan Cernja
Development
07/21/26 / 8 Min Read
Development
07/21/26 / 8 Min Read
Sandboxing an agent's code isn't the same as trusting it
A sandbox keeps an agent's code contained. It can't tell you the code is correct, which for backend code is the harder problem.
Ivan Cernja
Development
07/15/26 / 7 Min Read
Development
07/15/26 / 7 Min Read
We compiled our TypeScript parser to WASM
How we compiled the Rust parser that reads infrastructure out of Encore code so it runs in the browser, and how we use it to reproduce the parser errors people report.
Ivan Cernja