Skip to content

FlagSchema ​

The runtime descriptor stored inside every FlagBuilder. Consumers (parser, help generator, resolution chain) read this to understand the flag's shape without touching generics.

Signatures ​

ts
interface FlagSchema<K extends FlagKind> {}

Members ​

Properties ​

[schemaBrand] ​

Type-only seal produced by createFlagSchema.

ts
[schemaBrand]: "flag";

aggregateStandard ​

Standard Schema v1 validator applied to the completed collection.

Set by .standard() on a collection builder, so the array or record the aggregation produced is validated as a whole after every element passed.

ts
aggregateStandard: StandardSchemaV1<unknown, unknown> | undefined;

aliases ​

Short/long aliases (e.g. [{ name: 'f', hidden: false }] for --force).

ts
aliases: readonly FlagAlias[];

configPath ​

Dotted config path for v0.2+ resolution (e.g. 'deploy.region').

ts
configPath: string | undefined;

defaultDescription ​

Human-readable replacement for the default value in help, or false to omit the default annotation.

ts
defaultDescription: string | false | undefined;

defaultValue ​

Runtime default value (if any).

ts
defaultValue: unknown;

deprecated ​

Deprecation marker.

  • undefined — not deprecated (default)
  • true — deprecated with no migration message
  • string — deprecated with a reason/migration message

When a deprecated flag is used, a warning is emitted to stderr. Help text shows [deprecated] or [deprecated: <reason>].

ts
deprecated: string | true | undefined;

description ​

Human-readable description for help text.

ts
description: HelpDescription | undefined;

duplicateKeys ​

How a repeated key combines when kind === 'keyValue'.

ts
duplicateKeys: "error" | "last" | "first";

duplicates ​

Duplicate policy for repeated CLI occurrences. See DuplicatePolicy.

ts
duplicates: DuplicatePolicy;

elementSchema ​

Element schema when kind === 'array' or kind === 'keyValue'.

ts
elementSchema: FlagSchema<"string" | "number" | "boolean" | "enum" | "custom" | "array" | "count" | "keyValue"> | undefined;

enumValues ​

Allowed literal values when kind === 'enum'.

ts
enumValues: readonly string[] | undefined;

envVar ​

Environment variable name for v0.2+ resolution.

ts
envVar: string | undefined;

kind ​

What kind of value this flag accepts.

ts
kind: FlagSchema.K;

negation ​

Negation settings when kind === 'boolean' and .negatable() was called (undefined otherwise). See FlagNegation.

ts
negation: FlagNegation | undefined;

numberConstraints ​

Numeric constraints when kind === 'number' (undefined otherwise).

Enforced at the parse and resolution boundaries. finite defaults to true, so Infinity is rejected even when no constraints object is set.

ts
numberConstraints: NumberConstraints | undefined;

parseFn ​

Custom parse function (only when kind === 'custom').

ts
parseFn: FlagParseFn<unknown> | undefined;

pathChecks ​

Filesystem checks for path-valued flags (set by flag.path()).

Validated after resolution through the runtime adapter.

ts
pathChecks: PathChecks | undefined;

presence ​

Current presence state.

ts
presence: "optional" | "required" | "defaulted";

prompt ​

Interactive prompt configuration for v0.3+ resolution.

ts
prompt: PromptConfig | undefined;

propagate ​

Whether this flag propagates to subcommands in nested command trees.

When true, the flag is automatically available to all descendant commands. A child command that defines a flag with the same name shadows the propagated parent flag.

ts
propagate: boolean;

sensitive ​

Whether values from this input must be kept out of user-facing projections.

ts
sensitive: boolean;

separator ​

CLI value separator for a collection kind (undefined otherwise).

When set, each CLI occurrence is split on this separator before element coercion, so --tag a,b --tag c yields ['a', 'b', 'c']. Other sources decode through FlagSchema.split.

ts
separator: string | undefined;

split ​

Env and stdin split policies for a collection kind (undefined otherwise).

A source the binding leaves out takes its default: comma-delimited for env, line-delimited for stdin.

ts
split: SourceSplitBinding | undefined;

standard ​

Standard Schema v1 validator applied to each resolved value.

When set, the value from any source (CLI, env, config, prompt, default) is validated after resolution via ~standard.validate. Sync and async validators are both awaited; issues surface as a CONSTRAINT_VIOLATED ValidationError. On a collection this validates every element, whether it rides here or on FlagSchema.elementSchema.

ts
standard: StandardSchemaV1<unknown, unknown> | undefined;

stdin ​

Stdin binding set by .stdin() (undefined when the flag never reads stdin). See StdinBinding.

ts
stdin: StdinBinding | undefined;

stringConstraints ​

String constraints when kind === 'string' (undefined otherwise).

Enforced at the parse and resolution boundaries, in fixed order: nonEmpty → minLength → maxLength → pattern.

ts
stringConstraints: StringConstraints | undefined;

unique ​

Deduplicate resolved array values when kind === 'array'.

Applied after all sources resolve, preserving first-seen order. Uses SameValueZero semantics (like Set).

ts
unique: boolean;

valueHint ​

Help placeholder label (e.g. 'url' renders as <url>).

Set by the sugar factories (flag.url(), flag.date(), …) so help output names the expected value shape; undefined falls back to the kind-derived hint.

ts
valueHint: string | undefined;

See Also ​

Released under the MIT License.