Form schema validation
use-form schema based validation with zod, yup, joi and superstruct
Docs
Package
Schema-based validation
@mantine/form has built-in support for Standard Schema –
a community specification implemented by many popular schema validation libraries including
zod, valibot,
and arktype. Use schemaResolver to validate
forms with any Standard Schema-compliant library without extra resolver packages.
Full list of supported libraries
If you do not know which schema validation library to choose, use zod – it is the most modern and developer-friendly library.
Sync and async schemas
By default, schemaResolver returns a function that may return a Promise, since the
Standard Schema specification allows async validation. Pass { sync: true } when you know
your schema is synchronous (e.g., Zod, Valibot) to get synchronous return types for
form.validate(), form.validateField(), and form.isValid().
zod
Installation:
Basic field validation:
Nested field validation:
List field validation:
Async validation – use schemaResolver without { sync: true } when your schema
includes async checks (e.g., checking if an email is already taken via an API call).
In this case, form.validate(), form.validateField(), and form.isValid() return promises: