Skip to content

x-to-zod / ZodBuilder / EmojiBuilder

Class: EmojiBuilder ​

Defined in: src/ZodBuilder/emoji.ts:20

EmojiBuilder: represents z.emoji() in Zod v4.

In v4, emoji validation is a top-level function that provides better type inference and tree-shaking compared to v3's z.string().emoji() method chain.

Example ​

typescript
// v4 mode
const emoji = new EmojiBuilder({ zodVersion: 'v4' });
emoji.text(); // => 'z.emoji()'

Extends ​

  • StringFormatBuilder<ZodEmoji, [Parameters<typeof z.emoji>[0]]>

Implements ​

  • BuilderFor<ZodEmoji>

Constructors ​

Constructor ​

ts
new EmojiBuilder(version?, params?): EmojiBuilder;

Defined in: src/ZodBuilder/emoji.ts:29

Parameters ​

version? ​

"v3" | "v4"

params? ​

| string | { abort?: boolean; error?: | string | $ZodErrorMap<NonNullable<$ZodIssueInvalidStringFormat | $ZodIssueInvalidType<unknown>>>; message?: string; pattern?: RegExp; }

string


Type Literal ​

{ abort?: boolean; error?: | string | $ZodErrorMap<NonNullable<$ZodIssueInvalidStringFormat | $ZodIssueInvalidType<unknown>>>; message?: string; pattern?: RegExp; }

abort? ​

boolean

If true, no later checks will be executed if this check fails. Default false.

error? ​

| string | $ZodErrorMap<NonNullable<$ZodIssueInvalidStringFormat | $ZodIssueInvalidType<unknown>>>

message? ​

string

Deprecated

This parameter is deprecated. Use error instead.

pattern? ​

RegExp

Returns ​

EmojiBuilder

Overrides ​

ts
StringFormatBuilder<
		ZodEmoji,
		[params?: Parameters<typeof z.emoji>[0]]
	>.constructor

Properties ​

_base64? ​

ts
optional _base64?: {
  params?: unknown;
} = undefined;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:24

params? ​

ts
optional params?: unknown;

Inherited from ​

ts
StringFormatBuilder._base64

_brandText? ​

ts
optional _brandText?: string = undefined;

Defined in: src/ZodBuilder/BaseBuilder.ts:125

Inherited from ​

NumberBuilder._brandText


_defaultValue? ​

ts
optional _defaultValue?: unknown = undefined;

Defined in: src/ZodBuilder/BaseBuilder.ts:122

Inherited from ​

NumberBuilder._defaultValue


_describeText? ​

ts
optional _describeText?: string = undefined;

Defined in: src/ZodBuilder/BaseBuilder.ts:124

Inherited from ​

NumberBuilder._describeText


_fallbackText? ​

ts
optional _fallbackText?: unknown = undefined;

Defined in: src/ZodBuilder/BaseBuilder.ts:126

Inherited from ​

NumberBuilder._fallbackText


_format? ​

ts
optional _format?: {
  format: string;
  params?: unknown;
} = undefined;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:20

format ​

ts
format: string;

params? ​

ts
optional params?: unknown;

Inherited from ​

ts
StringFormatBuilder._format

_json? ​

ts
optional _json?: {
  params?: unknown;
} = undefined;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:25

params? ​

ts
optional params?: unknown;

Inherited from ​

ts
StringFormatBuilder._json

_maxLength? ​

ts
optional _maxLength?: {
  params?: unknown;
  value: number;
} = undefined;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:23

params? ​

ts
optional params?: unknown;

value ​

ts
value: number;

Inherited from ​

ts
StringFormatBuilder._maxLength

_metaData? ​

ts
optional _metaData?: Record<string, unknown> = undefined;

Defined in: src/ZodBuilder/BaseBuilder.ts:130

Inherited from ​

NumberBuilder._metaData


_minLength? ​

ts
optional _minLength?: {
  params?: unknown;
  value: number;
} = undefined;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:22

params? ​

ts
optional params?: unknown;

value ​

ts
value: number;

Inherited from ​

ts
StringFormatBuilder._minLength

_nullable ​

ts
_nullable: boolean = false;

Defined in: src/ZodBuilder/BaseBuilder.ts:120

Inherited from ​

NumberBuilder._nullable


_optional ​

ts
_optional: boolean = false;

Defined in: src/ZodBuilder/BaseBuilder.ts:119

Inherited from ​

NumberBuilder._optional


_params? ​

ts
protected optional _params?: [
  | string
  | {
  abort?: boolean;
  error?:   | string
     | $ZodErrorMap<NonNullable<$ZodIssueInvalidStringFormat | $ZodIssueInvalidType<unknown>>>;
  message?: string;
  pattern?: RegExp;
}];

Defined in: src/ZodBuilder/BaseBuilder.ts:118

Inherited from ​

ts
StringFormatBuilder._params

_pattern? ​

ts
optional _pattern?: {
  params?: unknown;
  pattern: string;
} = undefined;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:21

params? ​

ts
optional params?: unknown;

pattern ​

ts
pattern: string;

Inherited from ​

ts
StringFormatBuilder._pattern

_pipe? ​

ts
optional _pipe?: {
  contentSchema: Builder;
  params?: unknown;
} = undefined;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:26

contentSchema ​

ts
contentSchema: Builder;

params? ​

ts
optional params?: unknown;

Inherited from ​

ts
StringFormatBuilder._pipe

_readonly ​

ts
_readonly: boolean = false;

Defined in: src/ZodBuilder/BaseBuilder.ts:121

Inherited from ​

NumberBuilder._readonly


_refineFn? ​

ts
optional _refineFn?: string = undefined;

Defined in: src/ZodBuilder/BaseBuilder.ts:127

Inherited from ​

NumberBuilder._refineFn


_refineMessage? ​

ts
optional _refineMessage?: string = undefined;

Defined in: src/ZodBuilder/BaseBuilder.ts:128

Inherited from ​

NumberBuilder._refineMessage


_superRefineFns ​

ts
_superRefineFns: string[] = [];

Defined in: src/ZodBuilder/BaseBuilder.ts:129

Inherited from ​

NumberBuilder._superRefineFns


_transformFn? ​

ts
optional _transformFn?: string = undefined;

Defined in: src/ZodBuilder/BaseBuilder.ts:131

Inherited from ​

NumberBuilder._transformFn


_version? ​

ts
protected optional _version?: "v3" | "v4";

Defined in: src/ZodBuilder/BaseBuilder.ts:133

Inherited from ​

ts
StringFormatBuilder._version

typeKind ​

ts
readonly typeKind: "emoji";

Defined in: src/ZodBuilder/emoji.ts:27

Implementation of ​

ts
BuilderFor.typeKind

Overrides ​

ts
StringFormatBuilder.typeKind

Accessors ​

zodVersion ​

Get Signature ​

ts
get protected zodVersion(): ZodVersion;

Defined in: src/ZodBuilder/BaseBuilder.ts:144

Get the target Zod version for code generation.

Returns ​

ZodVersion

'v3' or 'v4' (default: 'v4')

Inherited from ​

ts
StringFormatBuilder.zodVersion

Methods ​

base() ​

ts
protected base(): string;

Defined in: src/ZodBuilder/emoji.ts:36

Compute the type-specific base schema string.

This is the core abstract method in the template method pattern. Subclasses must implement this to provide their type-specific schema string (e.g., "z.string()", "z.number()", "z.object({...})").

The base schema string returned by this method will then have shared modifiers applied via the modify() method when text() is called.

Returns ​

string

The base Zod schema string without any modifiers applied

Overrides ​

ts
StringFormatBuilder.base

brand() ​

ts
brand(brand): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:232

Apply brand modifier.

Parameters ​

brand ​

string

Returns ​

this

Implementation of ​

ts
BuilderFor.brand

Inherited from ​

ts
StringFormatBuilder.brand

catch() ​

ts
catch(fallback): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:248

Apply catch modifier.

Parameters ​

fallback ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.catch

Inherited from ​

ts
StringFormatBuilder.catch

date() ​

ts
date(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:133

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.date

datetime() ​

ts
datetime(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:127

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.datetime

default() ​

ts
default(value): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:212

Apply default value.

Parameters ​

value ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.default

Inherited from ​

ts
StringFormatBuilder.default

describe() ​

ts
describe(description): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:220

Apply describe modifier.

Parameters ​

description ​

string

Returns ​

this

Implementation of ​

ts
BuilderFor.describe

Inherited from ​

ts
StringFormatBuilder.describe

duration() ​

ts
duration(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:136

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.duration

e164() ​

ts
e164(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:148

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.e164

endsWith() ​

ts
endsWith(_value, _params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:91

Parameters ​

_value ​

string

_params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.endsWith

Inherited from ​

ts
StringFormatBuilder.endsWith

format() ​

ts
format(format, params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:42

Apply format constraint.

Parameters ​

format ​

string

params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.format

guid() ​

ts
guid(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:139

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.guid

hasConstraints() ​

ts
hasConstraints(): boolean;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:31

Check if this builder has any constraints applied.

Returns ​

boolean

Inherited from ​

ts
StringFormatBuilder.hasConstraints

includes() ​

ts
includes(_value, _params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:85

Parameters ​

_value ​

string

_params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.includes

Inherited from ​

ts
StringFormatBuilder.includes

ip() ​

ts
ip(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:121

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.ip

is() ​

ts
is<K>(type): this is TypeKindOf<K>;

Defined in: src/ZodBuilder/BaseBuilder.ts:308

Type Parameters ​

K ​

K extends | "symbol" | "undefined" | "null" | "any" | "void" | "never" | "unknown" | "nan"

Parameters ​

type ​

K

Returns ​

this is TypeKindOf<K>

Inherited from ​

ts
StringFormatBuilder.is

isV3() ​

ts
protected isV3(): boolean;

Defined in: src/ZodBuilder/BaseBuilder.ts:158

Check if targeting Zod v3.

Returns ​

boolean

Inherited from ​

ts
StringFormatBuilder.isV3

isV4() ​

ts
protected isV4(): boolean;

Defined in: src/ZodBuilder/BaseBuilder.ts:151

Check if targeting Zod v4.

Returns ​

boolean

Inherited from ​

ts
StringFormatBuilder.isV4

json() ​

ts
json(params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:73

Apply JSON transform.

Parameters ​

params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.json

ksuid() ​

ts
ksuid(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:145

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.ksuid

length() ​

ts
length(_len, _params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:94

Parameters ​

_len ​

number

_params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.length

Inherited from ​

ts
StringFormatBuilder.length

lowercase() ​

ts
lowercase(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:100

Parameters ​

_params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.lowercase

Inherited from ​

ts
StringFormatBuilder.lowercase

max() ​

ts
max(value, params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:65

Apply maxLength constraint.

Parameters ​

value ​

number

params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.max

Inherited from ​

ts
StringFormatBuilder.max

meta() ​

ts
meta(metadata): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:277

Apply meta modifier.

Parameters ​

metadata ​

Record<string, unknown>

Returns ​

this

Implementation of ​

ts
BuilderFor.meta

Inherited from ​

ts
StringFormatBuilder.meta

min() ​

ts
min(value, params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:57

Apply minLength constraint.

Parameters ​

value ​

number

params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.min

Inherited from ​

ts
StringFormatBuilder.min

modify() ​

ts
protected modify(baseText): string;

Defined in: src/ZodBuilder/BaseBuilder.ts:316

Apply all shared modifiers to the base schema string. This method is called by text() and applies modifiers in a stable order.

Parameters ​

baseText ​

string

Returns ​

string

Inherited from ​

ts
StringFormatBuilder.modify

nonempty() ​

ts
nonempty(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:97

Parameters ​

_params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.nonempty

Inherited from ​

ts
StringFormatBuilder.nonempty

normalize() ​

ts
normalize(_form?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:109

Parameters ​

_form? ​

string

Returns ​

this

Implementation of ​

ts
BuilderFor.normalize

Inherited from ​

ts
StringFormatBuilder.normalize

nullable() ​

ts
nullable(): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:204

Apply nullable constraint.

Returns ​

this

Implementation of ​

ts
BuilderFor.nullable

Inherited from ​

ts
StringFormatBuilder.nullable

optional() ​

ts
optional(): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:191

Apply optional constraint.

Returns ​

this

Implementation of ​

ts
BuilderFor.optional

Inherited from ​

ts
StringFormatBuilder.optional

pipe() ​

ts
pipe(contentSchema, params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:79

Apply pipe with parsed content schema.

Parameters ​

contentSchema ​

Builder

params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.pipe

readonly() ​

ts
readonly(): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:240

Apply readonly modifier.

Returns ​

this

Implementation of ​

ts
BuilderFor.readonly

Inherited from ​

ts
StringFormatBuilder.readonly

refine() ​

ts
refine(refineFn, message?): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:258

Apply refine modifier.

Note: function is provided as raw code string e.g. (val) => val > 0.

Parameters ​

refineFn ​

string

message? ​

string

Returns ​

this

Implementation of ​

ts
BuilderFor.refine

Inherited from ​

ts
StringFormatBuilder.refine

regex() ​

ts
regex(pattern, params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:48

Apply regex pattern constraint.

Parameters ​

pattern ​

string | RegExp

params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.regex

Inherited from ​

ts
StringFormatBuilder.regex

required() ​

ts
required(): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:196

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.required

safe() ​

ts
safe(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:124

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.safe

serializeParams() ​

ts
protected serializeParams(): string;

Defined in: src/ZodBuilder/BaseBuilder.ts:167

Serialize params to a string representation for code generation. Handles objects, strings, primitives, and undefined.

Returns ​

string

String representation of params or empty string if no params

Inherited from ​

ts
StringFormatBuilder.serializeParams

slugify() ​

ts
slugify(): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:118

Returns ​

this

Implementation of ​

ts
BuilderFor.slugify

Inherited from ​

ts
StringFormatBuilder.slugify

startsWith() ​

ts
startsWith(_value, _params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:88

Parameters ​

_value ​

string

_params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.startsWith

Inherited from ​

ts
StringFormatBuilder.startsWith

superRefine() ​

ts
superRefine(superRefineFn): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:269

Apply superRefine modifier.

Note: function is provided as raw code string e.g. (val, ctx) => { ... }.

Parameters ​

superRefineFn ​

string

Returns ​

this

Implementation of ​

ts
BuilderFor.superRefine

Inherited from ​

ts
StringFormatBuilder.superRefine

text() ​

ts
text(): string;

Defined in: src/ZodBuilder/BaseBuilder.ts:366

Unwrap and return the final Zod code string. This orchestrates the template method pattern: text() = modify(base())

Returns ​

string

Implementation of ​

ts
BuilderFor.text

Inherited from ​

ts
StringFormatBuilder.text

time() ​

ts
time(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:130

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.time

toLowerCase() ​

ts
toLowerCase(): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:112

Returns ​

this

Implementation of ​

ts
BuilderFor.toLowerCase

Inherited from ​

ts
StringFormatBuilder.toLowerCase

toString() ​

ts
toString(): string;

Defined in: src/ZodBuilder/BaseBuilder.ts:370

Returns a string representation of an object.

Returns ​

string

Inherited from ​

ts
StringFormatBuilder.toString

toUpperCase() ​

ts
toUpperCase(): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:115

Returns ​

this

Implementation of ​

ts
BuilderFor.toUpperCase

Inherited from ​

ts
StringFormatBuilder.toUpperCase

transform() ​

ts
transform(transformFn): this;

Defined in: src/ZodBuilder/BaseBuilder.ts:287

Apply transform modifier.

Note: function is provided as raw code string e.g. (val) => transformedVal.

Parameters ​

transformFn ​

string

Returns ​

this

Implementation of ​

ts
BuilderFor.transform

Inherited from ​

ts
StringFormatBuilder.transform

trim() ​

ts
trim(): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:106

Returns ​

this

Implementation of ​

ts
BuilderFor.trim

Inherited from ​

ts
StringFormatBuilder.trim

uppercase() ​

ts
uppercase(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:103

Parameters ​

_params? ​

unknown

Returns ​

this

Implementation of ​

ts
BuilderFor.uppercase

Inherited from ​

ts
StringFormatBuilder.uppercase

xid() ​

ts
xid(_params?): this;

Defined in: src/ZodBuilder/StringFormatBuilder.ts:142

Parameters ​

_params? ​

unknown

Returns ​

this

Inherited from ​

ts
StringFormatBuilder.xid

Released under the ISC License.