Valibot v1.1 release notes


Valibot v1.1 is out! This version comes with many new actions and methods to simplify your code even more! For example, you can now define a custom error message with our new message
method for multiple schemas and actions at once, or use our new summarize
method to summarize your validation errors into a pretty-printable multi-line string.
This is our first minor release since v1, and it is worth mentioning that there has been no need for a patch release since then. The work we put into our type and unit tests to reach 100% test coverage is paying off! Before we dive into the details of Valibot v1.1, I want to give a quick update on our newest partners and contributors.
New partners and contributors
We are excited to announce Motion as our newest partner. Motion builds an AI-powered project management software and uses Valibot to validate user input in their web application. They are a great example of how Valibot can be used at scale in a real-world application, and we are thrilled to have them on board. In addition, DigitalOcean has extended their support and we will soon be able to announce another exciting partnership.
We would also like to welcome @muningis and @EskiMojo14 as new contributors to the project, who have had a big impact on this release. Thank you for your hard work and dedication to making Valibot better for everyone!
Easier custom error messages
Previously, it was a bit cumbersome to define the same custom error messages for multiple schemas and actions. You could use our config
method or just repeat the same message over and over again. With Valibot v1.1 this got a lot easier! You can now use the message
method to define a custom error message for multiple schemas and actions at once.
const EmailSchema = v.message(
v.pipe(v.string(), v.trim(), v.nonEmpty(), v.email(), v.maxLength(100)),
'The email is not in the required format.'
);
Simpler error pretty-printing
Inspired by Zod v4's new prettifyError
method and pushed by @MOZGIII's feedback on GitHub, we now provide an official way to format all your validation errors into a pretty printable multi-line string. This is especially useful for debugging and logging purposes, as it gives you a great overview of everything that went wrong.
Imagine the following issues returned after the user entered invalid data into a login form:
[
{
kind: "validation",
type: "email",
input: "jane@example",
expected: null,
received: "\"jane@example\"",
message: "Invalid email: Received \"jane@example\"",
requirement: /^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu,
path: [...],
}, {
kind: "validation",
type: "min_length",
input: "1234567",
expected: ">=8",
received: "7",
message: "Invalid length: Expected >=8 but received 7",
requirement: 8,
path: [...],
}
]
Using the new summarize
method, you can now format this into a human-readable string:
× Invalid email: Received "jane@example"
→ at email
× Invalid length: Expected >=8 but received 7
→ at password
We will consider using summarize
for the default error message when throwing a ValiError
for Valibot's next major release. Please join this issue on GitHub to discuss with us.
Extract metadata with one line
A probably still very underrated feature are our metadata actions. With title
, description
and metadata
we provide 3 common metadata actions already out-of-the-box. But Valibot's modularity also allows you to build your own metdata actions on top! For example, this allows you to build your own ORM on top of Valibot to define the schema of your models.
import * as o from 'orm-actions';
import * as v from 'valibot';
const UserTableSchema = v.pipe(
v.object({
id: v.pipe(v.number(), v.integer(), o.primaryKey()),
name: v.pipe(v.string(), v.nonEmpty(), o.index()),
email: v.pipe(v.string(), v.email(), o.index()),
// ...
}),
o.table('users')
);
With Valibot v1.1 we have expanded our out-of-the-box capabilities with 3 new methods. With getTitle
, getDescription
and getMetadata
you can now extract the metadata of a schema with a single line of code. All 3 methods use special algorithms to extract the correct metadata even if multiple metadata actions are defined. For example, getMetadata
shallow merges multiple metadata using depth-first search and returns a correctly typed object.
const Schema1 = v.pipe(v.string(), v.metadata({ key1: 'foo', key2: 'bar' }));
const Schema2 = v.pipe(Schema1, v.metadata({ key2: 'baz', key3: 'qux' }));
const metadata = v.getMetadata(Schema2); // { key1: 'foo', key2: 'baz', key3: 'qux' }
Parse and stringify JSON
A probably long awaited feature was a native way to parse and stringify JSON in Valibot's pipelines. This is now possible with our new parseJson
and stringifyJson
transformation actions. They automatically catch errors and take care of all edge cases, and you can combine them with other schemas and actions for 100% reliable results.
const ProductSchema = v.pipe(
v.string(),
v.parseJson(),
v.object({
id: v.pipe(v.string(), v.uuid()),
name: v.pipe(v.string(), v.nonEmpty()),
price: v.pipe(v.number(), v.minValue(0)),
tags: v.pipe(v.array(v.string()), v.maxLength(10)),
})
);
For a full list of new features and changes, please see the release notes on GitHub.
The future is bright!
@EltonLobo07 has started working on an official Zod-to-Valibot codemod! We will be releasing some updates and demos soon. We also plan to focus a bit more on educating developers on the benefits of choosing Valibot. Stay tuned for more content on social media and this blog in the coming weeks and months!
We have also started using milestones on GitHub to keep track of our progress and give you a better overview of what we are currently working on. Feel free to take a look at what's coming in Valibot v1.2 and beyond and please contact us if you have any questions or suggestions. We are always happy to hear from you!