Skip to Content

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.

RuleValibotZod
string.min_len, max_len, lenminLength, maxLength, lengthminLength, maxLength, length
string.min_bytes, max_bytes, len_bytesminBytes, maxBytes, bytesrefine
string.patternregexregex
string.prefix, suffix, containsstartsWith, endsWith, includesstartsWith, endsWith, includes
string.not_containsexcludesrefine
string.email, uri, ipv4, ipv6, ulidemail, url, ipv4, ipv6, ulidemail, url, ipv4, ipv6, ulid
string.uuiduuidguid
numeric gt, gte, lt, ltegtValue, minValue, ltValue, maxValuegt, gte, lt, lte
const, inliteral, picklistliteral
not_innotValuesrefine
float.finite, double.finitefinitenothing, z.number() rejects infinite values
bool.constliteralliteral
bytes.len, min_len, max_lenlength, minLength, maxLengthlength, minLength, maxLength
enum.defined_onlypicklistliteral
repeated.min_items, max_itemsminLength, maxLengthminLength, maxLength
repeated.uniquecheckrefine
repeated.items, map.keys, map.valuesapplied to the element schemaapplied to the element schema
map.min_pairs, max_pairsminEntries, maxEntriesrefine
(buf.validate.oneof).requiredno { case: undefined } caseno { case: undefined } case

required

FieldEffect
with presencethe key is required
string, bytesthe value is not empty
number, enumthe value is not 0
boolthe value is true
repeated, mapthe value has at least one element

ignore

ValueEffect
IGNORE_ALWAYSThe field has no rules. A message field accepts any value.
IGNORE_IF_ZERO_VALUEA 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.