Rule mapping
The Valibot or Zod check that each protovalidate rule becomes.
The plugin uses a standard action of the library whenever one exists. A standard action has an issue type, so the message overrides and the locales apply. The plugin uses v.check and z.refine only where no standard action exists. Those checks report the generic message of the library.
| Rule | Valibot | Zod |
|---|---|---|
string.min_len, max_len, len | minLength, maxLength, length | minLength, maxLength, length |
string.min_bytes, max_bytes, len_bytes | minBytes, maxBytes, bytes | refine |
string.pattern | regex | regex |
string.prefix, suffix, contains | startsWith, endsWith, includes | startsWith, endsWith, includes |
string.not_contains | excludes | refine |
string.email, uri, ipv4, ipv6, ulid | email, url, ipv4, ipv6, ulid | email, url, ipv4, ipv6, ulid |
string.uuid | uuid | guid |
numeric gt, gte, lt, lte | gtValue, minValue, ltValue, maxValue | gt, gte, lt, lte |
const, in | literal, picklist | literal |
not_in | notValues | refine |
float.finite, double.finite | finite | nothing, z.number() rejects infinite values |
bool.const | literal | literal |
bytes.len, min_len, max_len | length, minLength, maxLength | length, minLength, maxLength |
enum.defined_only | picklist | literal |
repeated.min_items, max_items | minLength, maxLength | minLength, maxLength |
repeated.unique | check | refine |
repeated.items, map.keys, map.values | applied to the element schema | applied to the element schema |
map.min_pairs, max_pairs | minEntries, maxEntries | refine |
(buf.validate.oneof).required | no { case: undefined } case | no { case: undefined } case |
required
| Field | Effect |
|---|---|
| with presence | the key is required |
string, bytes | the value is not empty |
| number, enum | the value is not 0 |
bool | the value is true |
repeated, map | the value has at least one element |
ignore
| Value | Effect |
|---|---|
IGNORE_ALWAYS | The field has no rules. A message field accepts any value. |
IGNORE_IF_ZERO_VALUE | A field without presence accepts the zero value first. A field with presence is unchanged. |
required wins when a field has both required and IGNORE_IF_ZERO_VALUE.
Read Options for the rules that the plugin does not translate.