Typings — String
Import
import type { IEmailValidationOptions, IUnitInfo, IUnitParserOptions, IUnitParserResult } from '@litert/utils-string';IEmailValidationOptions
Source: IsEmailAddress.ts
Extra options for isEmailAddress.
interface IEmailValidationOptions {
maxLength?: number;
domains?: string[];
}Properties
maxLength?: number(default:255)The maximum allowed length for the email address. If this value exceeds
255,255is 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.
interface IUnitInfo {
name: string;
aliases?: readonly string[];
}Properties
name: stringThe canonical name of the unit. This value is returned in
IUnitParserResult.unitregardless of how it was matched.aliases?: readonly string[]Additional strings that should match this unit. When
caseInsensitiveistrue, aliases are stored in lowercase for matching, butnameis always returned as-is.
IUnitParserOptions
Source: UnitParser.ts
Constructor options for UnitParser.
interface IUnitParserOptions {
format: string;
units: ReadonlyArray<string | IUnitInfo>;
caseInsensitive?: boolean;
maxDecimalPlaces?: number;
}Properties
format: stringThe 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
IUnitInfoobject — with a canonicalnameand optionalaliases.
- A plain
caseInsensitive?: boolean(default:true)Whether unit matching ignores case. The canonical
namefromIUnitInfois 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().
interface IUnitParserResult {
value: string;
unit: string;
}Properties
value: stringThe numeric portion of the parsed string, as a string (e.g.,
'12.5').unit: stringThe canonical unit name matched. This is the
namefield fromIUnitInfo, not the matched alias.
Constants
ERandomStringCharset
An enum of predefined character sets for use with the random function.
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',
}| Member | Value | Description |
|---|---|---|
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
The default character set used by random when no explicit charset is provided. Combines uppercase letters, lowercase letters, and digits.
import { DEFAULT_RANDOM_CHARSET } from '@litert/utils-string';
const DEFAULT_RANDOM_CHARSET: string;
// = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'