env/env_schemas.ts

@fuzdev/fuz_schema schemas for env var values, matching the Rust spine's readers of the same vars.

An env value is a string, so these take a string and output the value it spells: env_integer for whole numbers, EnvStringbool for booleans.

view source

Declarations
#

3 declarations

env_integer
#

env/env_schemas.ts view source

(options?: EnvIntegerOptions | undefined): PipeSchema<number, StringSchema> import {env_integer} from '@fuzdev/fuz_app/env/env_schemas.js';

A whole number spelled in decimal digits, read the way the Rust spine reads one (value.trim().parse::<u64>()): trimmed of Unicode White_Space (the set Rust's trim strips, not String.prototype.trim's), then decimal digits after at most one leading +, so a blank value, a -, a fraction, an exponent (5e3), and hex (0x1F90) are refused, and +80 and leading zeros (00080) are not. The number must be a safe integer within min and max.

options?

the bounds, default 0 to Number.MAX_SAFE_INTEGER

optional

returns

PipeSchema

EnvIntegerOptions
#

env/env_schemas.ts view source

EnvIntegerOptions import type {EnvIntegerOptions} from '@fuzdev/fuz_app/env/env_schemas.js';

Options of env_integer.

min?

The least value accepted, default 0.

type number

max?

The greatest value accepted, default Number.MAX_SAFE_INTEGER.

type number

EnvStringbool
#

env/env_schemas.ts view source

PipeSchema<boolean, StringSchema>

type PipeSchema

import {EnvStringbool} from '@fuzdev/fuz_app/env/env_schemas.js';

A boolean spelled as a word, matched case-insensitively and not trimmed: true, 1, yes, on, y, or enabled for true, and false, 0, no, off, n, or disabled for false. Anything else is refused, '' and ' true' included, so a typo doesn't silently flip a feature.

The twin of the Rust spine's parse_stringbool, its set and its case rule.

Depends on
#

Imported by
#