Skip to content

Typings — String

Import

ts
import type { IEmailValidationOptions, IUnitInfo, IUnitParserOptions, IUnitParserResult } from '@litert/utils-string';

IEmailValidationOptions

Source: IsEmailAddress.ts

Extra options for isEmailAddress.

ts
interface IEmailValidationOptions {
    maxLength?: number;
    domains?: string[];
}

Properties

  • maxLength?: number (default: 255)

    The maximum allowed length for the email address. If this value exceeds 255, 255 is used instead.

  • domains?: string[] (default: [])

    An allowlist of permitted email domains. When provided (and non-empty), only email addresses whose domain is in this list are accepted. Comparison is case-insensitive, but only lowercase domain strings in the list are supported.


IUnitInfo

Source: UnitParser.ts

Describes a single unit accepted by UnitParser.

ts
interface IUnitInfo {
    name: string;
    aliases?: readonly string[];
}

Properties

  • name: string

    The canonical name of the unit. This value is returned in IUnitParserResult.unit regardless of how it was matched.

  • aliases?: readonly string[]

    Additional strings that should match this unit. When caseInsensitive is true, aliases are stored in lowercase for matching, but name is always returned as-is.


IUnitParserOptions

Source: UnitParser.ts

Constructor options for UnitParser.

ts
interface IUnitParserOptions {
    format: string;
    units: ReadonlyArray<string | IUnitInfo>;
    caseInsensitive?: boolean;
    maxDecimalPlaces?: number;
}

Properties

  • format: string

    The expected string format. Use {value} as a placeholder for the numeric part and {unit} for the unit part. Both placeholders are required.

    '{value}{unit}'       → matches '12.5km'
    '{value} {unit}'      → matches '12.5 km'
    '{value}_{unit}'      → matches '12_km'
  • units: ReadonlyArray<string | IUnitInfo>

    The list of recognized units. Each element can be:

    • A plain string — treated as { name: str, aliases: [str] }.
    • An IUnitInfo object — with a canonical name and optional aliases.
  • caseInsensitive?: boolean (default: true)

    Whether unit matching ignores case. The canonical name from IUnitInfo is always returned as-is.

  • maxDecimalPlaces?: number (default: 2)

    The maximum number of digits allowed after the decimal point in the {value} portion. Must be a non-negative integer.


IUnitParserResult

Source: UnitParser.ts

The return type of UnitParser.parse().

ts
interface IUnitParserResult {
    value: string;
    unit: string;
}

Properties

  • value: string

    The numeric portion of the parsed string, as a string (e.g., '12.5').

  • unit: string

    The canonical unit name matched. This is the name field from IUnitInfo, not the matched alias.


Constants

ERandomStringCharset

Source: packages/partials/string/src/Functions/Random.ts

An enum of predefined character sets for use with the random function.

ts
import { ERandomStringCharset } from '@litert/utils-string';

enum ERandomStringCharset {
    UPPER_ALPHA     = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    LOWER_ALPHA     = 'abcdefghijklmnopqrstuvwxyz',
    DEC_DIGIT       = '0123456789',
    UPPER_HEX_DIGIT = '0123456789ABCDEF',
    LOWER_HEX_DIGIT = '0123456789abcdef',
}
MemberValueDescription
UPPER_ALPHA'ABCDEFGHIJKLMNOPQRSTUVWXYZ'Uppercase English letters
LOWER_ALPHA'abcdefghijklmnopqrstuvwxyz'Lowercase English letters
DEC_DIGIT'0123456789'Decimal digits 0–9
UPPER_HEX_DIGIT'0123456789ABCDEF'Uppercase hexadecimal digits
LOWER_HEX_DIGIT'0123456789abcdef'Lowercase hexadecimal digits

DEFAULT_RANDOM_CHARSET

Source: packages/partials/string/src/Functions/Random.ts

The default character set used by random when no explicit charset is provided. Combines uppercase letters, lowercase letters, and digits.

ts
import { DEFAULT_RANDOM_CHARSET } from '@litert/utils-string';

const DEFAULT_RANDOM_CHARSET: string;
// = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'