Skip to content

StringConstraints

Runtime string constraints attached to a string flag/arg schema.

Length bounds are inclusive and measured in UTF-16 code units (String.prototype.length). All fields are optional; an absent field means "no constraint".

Signatures

ts
interface StringConstraints {}

Members

Properties

maxLength

Inclusive maximum length. Longer values are rejected.

ts
maxLength?: number;

minLength

Inclusive minimum length. Shorter values are rejected.

ts
minLength?: number;

nonEmpty

Reject empty strings (''). Whitespace-only strings are still accepted; combine with pattern for stricter rules.

ts
nonEmpty?: boolean;

pattern

Regular expression the value must match. Tested with RegExp.prototype.test; anchor with ^/$ for full-string matching.

ts
pattern?: RegExp;

See Also

Released under the MIT License.