Skip to content

createFlagSchema

Generated reference page for the createFlagSchema function export.

Signatures

Overload 1

ts
function createFlagSchema<K extends "string" | "number" | "boolean" | "enum" | "array" | "custom" | "count" | "keyValue">(kind: K, overrides?: FlagDefinitionOverrides<K>): FlagSchema<K>;
ParameterTypeDescription
kindKDiscriminator for the value type this flag accepts.
overridesFlagDefinitionOverrides<K> | undefinedDefinition fields for kind, shallow-merged onto defaults.

Overload 2

ts
function createFlagSchema<K extends "string" | "number" | "boolean" | "enum" | "array" | "custom" | "count" | "keyValue">(definition: FlagSchema<K> | FlagDefinition<K>): FlagSchema<K>;
ParameterTypeDescription
definitionFlagSchema<K> | FlagDefinition<K>Kind discriminator plus the fields valid for that kind.

Members

Members

createFlagSchema

Create a raw FlagSchema object with sensible defaults.

Most consumers should prefer the higher-level flag factory, which returns an immutable FlagBuilder with type inference and safe modifier chaining. createFlagSchema() is the low-level escape hatch for advanced schema composition, tests, or custom factories that need the plain runtime descriptor.

Fields are shallow-merged on top of the default shape, so callers are responsible for keeping the resulting schema internally consistent.

ts
(kind: K, overrides?: FlagDefinitionOverrides<K>): FlagSchema<K>;

createFlagSchema

Create a raw FlagSchema object from a single definition object.

An already-built FlagSchema is accepted and re-normalized into a deep-equal schema.

ts
(definition: FlagSchema<K> | FlagDefinition<K>): FlagSchema<K>;

Examples

ts
const schema = createFlagSchema('enum', {
  enumValues: ['us', 'eu', 'ap'],
  description: 'Deployment region',
});
ts
const schema = createFlagSchema({
  kind: 'array',
  elementSchema: { kind: 'string' },
  separator: ',',
});

See Also

Released under the MIT License.