Skip to main content

Comparison

A comparison between other object/schema validation libraries in the JavaScript ecosystem.

APIs#

optimalyupjoizod
Async validation✅✅✅
Custom error mesages✅✅
Deep path validation✅
Dependency count0750
File size (unminified)47kB152kB430kB217kB
File size (minified)16.6kB59.5kB145.1kB49kB
File size (gzipped)4.7kB18.1kB41.8kB11.2kB
Immutable schemas✅✅✅✅
Lazy default values✅✅✅✅
Lazy schemas✅✅✅
Localization✅
Native TypeScript✅✅
Nullable fields✅✅✅
Predicates✅
Required/optional fields✅✅✅✅
Tree-shakable✅✅✅
Type casting✅✅✅
Undefined fields✅✅
Value transformation✅✅✅✅

Common methods#

This functionality is available across all schema types, typically as chainable methods.

  • 1️⃣ - Only supports these on objects/shapes.
optimalyupjoizod
and1️⃣1️⃣✅
any✅
custom handler✅✅
default value✅✅✅✅
defined✅
deprecate✅
nand1️⃣
never✅✅✅
not nullable✅
not required✅✅✅
nullable✅✅✅
only✅✅
or1️⃣1️⃣
oxor1️⃣
required✅✅✅
undefined✅✅
unknown✅
void✅
when✅✅✅
xor1️⃣1️⃣

Arrays#

The array() schema for arrays.

  • 1️⃣ - Supported through transformers.
optimalyupjoizod
filter1️⃣✅1️⃣
has✅
items schema✅✅✅
length✅✅✅
max✅✅✅
min✅✅✅
not empty✅✅✅✅
order1️⃣1️⃣✅1️⃣
sort1️⃣1️⃣✅1️⃣
unique1️⃣1️⃣✅1️⃣

Binary#

The binary() schema for binary/blob values.

optimal ❌yup ❌joizod ❌
encoding✅
length✅
max✅
min✅

Booleans#

The bool() (or boolean()) schema for booleans.

optimalyupjoizod
falsy values✅
only false✅
only true✅
truthy values✅

Class instances#

The instance() (or instanceof()) schema for class instances.

  • 1️⃣ - joi only supports these on object.instance().
optimalyup ❌joizod
inheritance✅1️⃣✅

Dates#

The date() schema for Dates.

optimalyupjoizod
after✅✅✅
before✅✅✅
between✅
iso✅
timestamp✅

Functions#

The func() (or function()) schema for functions.

optimalyup ❌joizod
arity✅
args✅
implements✅
return✅

IDs / UUIDs#

The id() and uuid() schemas for record identifiers.

  • For non-optimal libs, they don't support UUID directly, see strings.
optimalyupjoizod
id✅
uuid✅✅✅✅

Lazy#

The lazy() schema for deferring evaluation, or recursive schemas.

optimalyupjoi ❌zod
*✅✅✅

Numbers#

The number() schema for numbers.

optimalyupjoizod
base✅
between✅
float✅
gt✅✅✅✅
gte✅✅✅
integer✅✅✅
lt✅✅✅✅
lte✅✅✅
max✅✅✅
min✅✅✅
negative✅✅✅✅
not one of✅
one of✅✅
precision✅
port✅
positive✅✅✅✅
rounding✅
sign✅

Objects / records#

The object() schema for indexed objects.

  • For joi and yup, they don't support this type, see shapes.
  • For zod, this is a record().
optimalyup ❌joi ❌zod
keys schema✅
length✅
not empty✅
values schema✅✅

Regex patterns#

The regex() schema for RegExp inheritance.

  • 1️⃣ - joi only supports these on object.regex().
optimalyup ❌joizod ❌
inheritance✅1️⃣

Shapes#

The shape() schema for shaped objects.

  • For yup, this is object().shape().
  • For joi and zod, this is object().
optimalyupjoizod
exact / unknown✅✅✅✅
extending✅✅✅
key rename✅
max✅
min✅
merge✅
omit✅✅
pick✅✅
with✅
without✅

Strings#

The string() schema for strings.

optimalyupjoizod
alphanumeric✅
base 64✅
camel case✅
contains✅
credit card✅
domain✅
email✅✅✅
hex✅
hostname✅
ip✅
kebab case✅✅
length✅✅✅✅
lower case✅✅✅
matches✅✅✅✅
max✅✅
min✅✅
not empty✅✅
not one of✅
one of✅✅
pascal case✅
snake case✅
replace✅
trim✅
truncate✅
token✅
upper case✅✅✅
uri✅
url✅✅
uuid✅✅✅

Symbols#

The symbol() schema for symbols.

optimal ❌yup ❌joizod ❌
*✅

Tuples#

The tuple() schema for tuples (fixed arrays).

optimalyup ❌joi ❌zod
members schema✅✅

Unions#

The union() schema for unions.

optimalyup ❌joi ❌zod
options schema✅✅

Other schemas#

optimalyupjoizod
any()✅
bigint()✅
enum()✅
literal()✅
map()✅
promise()✅
set()✅