UMT Main Package is written in TypeScript and is a collection of useful functions for various tasks.
npm install umtUMT Main Package is written in TypeScript and is a collection of useful functions for various tasks.
``bash
npm install umt
yarn add umt
pnpm add umt
bun add umt
`
| name | type | description | example |
|------|------|-------------|---------|
| rangeAdvance | (start: number, end?: number, conditionalExpression?: (n: number) => boolean) => number[] | Returns an array of numbers that satisfy the conditional expression | rangeAdvance(1, 10, (n) => n % 2 === 0); // [2, 4, 6, 8] |
| name | type | description | example |
|------|------|-------------|---------|
| PriorityQueue | class PriorityQueue | A priority queue implementation using a binary heap. Higher priority values are dequeued first. | const queue = new PriorityQueue |
| name | type | description | example |
|------|------|-------------|---------|
| cmykToRgba | (c: number, m: number, y: number, k: number, a?: number) => { r: number; g: number; b: number; a: number } | Convert CMYK color values to RGBA color space | cmykToRgba(100, 100, 0, 60.78) // { r: 0, g: 0, b: 100, a: 1 } |(hex: string) => { r: number; g: number; b: number; a: number }
| hexaToRgba | | Convert hexadecimal color code to RGBA color values | hexaToRgba("#00000000") // { r: 0, g: 0, b: 0, a: 0 } |(h: number, s: number, l: number, a?: number) => { r: number; g: number; b: number; a: number }
| hslaToRgba | | Convert HSLA color values to RGBA color space | hslaToRgba(120, 50, 50, 1) // { r: 64, g: 191, b: 64, a: 1 } |(rgba: { r: number; g: number; b: number; a?: number }) => { c: number; m: number; y: number; k: number; a: number }
| rgbaToCmyk | | Convert RGBA color to CMYK color model | rgbaToCmyk({ r: 0, g: 0, b: 0, a: 1 }); // { c: 0, m: 0, y: 0, k: 100, a: 1 } |(rgba: { r: number; g: number; b: number; a?: number }) => string
| rgbaToHexA | | Convert RGBA color to hexadecimal color code | rgbaToHexA({ r: 0, g: 0, b: 0, a: 1 }); // "#000000ff" |(rgba: { r: number; g: number; b: number; a?: number }) => { h: number; s: number; l: number; a: number }
| rgbaToHsla | | Convert RGBA color values to HSLA color space | rgbaToHsla({ r: 100, g: 100, b: 100, a: 1 }); // { h: 0, s: 0, l: 39.22, a: 1 } |
| name | type | description | example |
|------|------|-------------|---------|
| decodeBase32 | (input: string) => Uint8Array | Decodes an uppercase Base32 string to Uint8Array. Does not validate padding placement. | decodeBase32("JBSWY3DP"); // Uint8Array for "Hello" |(input: string) => string
| decodeBase32ToString | | Decodes an uppercase Base32 string to a UTF-8 string. Does not validate padding placement. | decodeBase32ToString("JBSWY3DP"); // "Hello" |(input: string) => Uint8Array
| decodeBase58 | | Decodes a Base58 string to Uint8Array | decodeBase58("9Ajdvzr"); // Uint8Array for "Hello" |(input: string) => string
| decodeBase58ToString | | Decodes a Base58 string to a UTF-8 string | decodeBase58ToString("9Ajdvzr"); // "Hello" |(input: string \| Uint8Array) => string
| encodeBase32 | | Encodes a string or Uint8Array to Base32 format | encodeBase32("Hello"); // "JBSWY3DP" |(input: string \| Uint8Array) => string
| encodeBase58 | | Encodes a string or Uint8Array to Base58 format | encodeBase58("Hello"); // "9Ajdvzr" |
| name | type | description | example |
|------|------|-------------|---------|
| birthday | | Calculate age based on birthdate | birthday(2000, 1, 1); // Returns age of someone born on Jan 1, 2000 |(startDate: Date, endDate: Date) => Date[]
| dateRange | | Generate an array containing all dates between the specified start and end dates | dateRange(new Date('2025-01-01'), new Date('2025-01-03')) |
| dayOfWeek | | Get the day of the week | dayOfWeek({ year: 2000, mon: 1, day: 1 }); |(date: Date, formatString?: string) => string
| format | | Converts a date to a string according to the specified format pattern | format(new Date('2025-04-04'), 'YYYY-MM-DD') // Returns "2025-04-04" |
| getDay | | Convert a number to a day of the week in the specified language | getDay(0, "en"); // Returns "Sun" |(instance: Date) => string
| getTimezoneOffsetString | | Get timezone offset string in format "+HH:mm" or "-HH:mm" | getTimezoneOffsetString(new Date()); // "+09:00" for JST |(year: number) => boolean
| isLeapYear | | Determine if a given year is a leap year | isLeapYear(2020); // Returns true |
| newDateInt | | Create a new Date object from numeric values | newDateInt(2021, 1, 1); // Creates date for January 1, 2021 |
| newDateString | | Create a new Date object from a string date and time components | newDateString("2021-01-01"); // Creates date for January 1, 2021 00:00:00 |(timeDifference?: HoursTypeInt) => Date
| now | | Get the current time with a specified UTC offset | now(); // Returns current time in JST (UTC+9) |
| name | type | description | example |
|------|------|-------------|---------|
| safeExecute | | Safely executes a callback function and returns a Result type | safeExecute(() => JSON.parse('{"a": 1}')); // {type: "success", value: {a: 1}} |
| name | type | description | example |
|------|------|-------------|---------|
| curry | (func: (...args: unknown[]) => unknown) => Function | Curries a function | const add = (a, b, c) => a + b + c; curry(add)(1)(2)(3); // 6 |
| name | type | description | example |
|------|------|-------------|---------|
| cidrToLong | (cidr: number) => number | Converts CIDR notation to a subnet mask number | cidrToLong(24); // 4294967040 |(cidr: number) => string
| cidrToSubnetMask | | Converts CIDR notation to a subnet mask | cidrToSubnetMask(24); // "255.255.255.0" |(ip: string) => string
| getIpClass | | Gets the IP address class (A, B, C, D, or E) | getIpClass("192.168.1.1"); // "C" |(ip: string, subnetMask: string) => number
| getNetworkAddress | | Calculates the network address from an IP address and subnet mask | getNetworkAddress("192.168.1.1", "255.255.255.0"); // 3232235776 |(ip: string) => string
| ipToBinaryString | | Converts an IPv4 address to its binary string representation | ipToBinaryString("192.168.1.1"); // "11000000101010000000000100000001" |(ip: string) => number
| ipToLong | | Converts an IPv4 address to a 32-bit number | ipToLong("192.168.1.1"); // 3232235777 |(remoteIp: string, networkIp: string, cidr: number) => boolean
| isInRange | | Checks if an IP address is within a specified network range | isInRange("192.168.1.100", "192.168.1.0", 24); // true |(ip: string) => boolean
| isPrivateIp | | Checks if an IP address is within private IP ranges | isPrivateIp("192.168.1.1"); // true |(long: number) => string
| longToIp | | Converts a 32-bit number to an IPv4 address | longToIp(3232235777); // "192.168.1.1" |(subnetMask: string) => number
| subnetMaskToCidr | | Converts a subnet mask to CIDR notation | subnetMaskToCidr("255.255.255.0"); // 24 |
| name | type | description | example |
|------|------|-------------|---------|
| addition | (...numbers: number[]) => number | Addition without floating point errors | addition(0.1, 0.2); // 0.3 |(numbers: number[]) => number
| average | | Calculates the arithmetic mean of an array of numbers | average([1, 2, 3]); // 2 |(x: number[], y: number[]) => number
| correlationCoefficient | | Calculate the Pearson correlation coefficient between two arrays | correlationCoefficient([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]); // 1 |(x: number, k: number, direction?: "left" \| "right") => number
| bitwise | | Performs bit rotation on a number | bitwise(0x12345678, 8); // 0x34567812 |
| calculator | | Calculator function that handles mathematical expressions and simple equations | calculator("1+2"); // "3" |
| calculatorInitialization | | Initializes a calculator function with exchange rates | calculatorInitialization({ $: 100 })("$1"); // "100" |
| convertCurrency | | Converts currency amounts in a string using currency symbols | convertCurrency("¥100", { "¥": 0.01 }); // "1" |(x: number) => number
| degToRad | | Converts degrees to radians | degToRad(180); // 3.141592653589793 |(value: number, averageValue: number, standardDeviationValue: number) => number
| deviationValue | | Calculate standard score (deviation value) | deviationValue(10, 5, 2); // 75 |
| division | | Performs division without floating point errors | division(0.1, 0.2); // 0.5 |(x: number) => number
| factorial | | Calculate factorial of a number | factorial(5); // 120 |(n: number) => number[]
| factorize | | Prime factorization of a number | factorize(12); // [2, 2, 3] |(value: unknown) => number
| flexibleNumberConversion | | Flexible function to convert various inputs to numbers whenever possible | flexibleNumberConversion("456"); // 456 |(x: number, y: number, ...z: number[]) => number
| gcd | | Greatest Common Divisor (GCD) | gcd(12, 18); // 6 |(value: number) => number
| getDecimalLength | | Gets the number of decimal places in a number | getDecimalLength(1.23); // 2 |(x: number, y: number) => number
| lcm | | Least Common Multiple (LCM) | lcm(2, 3); // 6 |(seed: number, max?: number, multiplier?: number, increment?: number) => number
| linearCongruentialGenerator | | Linear Congruential Generator for random number generation | linearCongruentialGenerator(12345); |(x: string) => string
| literalExpression | | Solves literal equations with variables | literalExpression("x+1=2"); // "1" |(equation: string) => string
| mathConverter | | Expands square of n into a sum of simpler multiplications | mathConverter("12501250"); // "15001000+400100+200100+50*50" |(input: string \| number) => [number, number]
| mathSeparator | | Separates a number at its highest place value | mathSeparator(1250); // [1000, 250] |(...number_: number[]) => number
| max | | Returns the maximum value from the input numbers | max(1, 2, 3); // 3 |(array: number[]) => number
| median | | Calculate the median of an array of numbers | median([1, 3, 3, 6, 7, 8, 9]); // 6 |(...number_: number[]) => number
| min | | Returns the minimum value from the input numbers | min(1, 2, 3); // 1 |(array: number[]) => number[]
| mode | | Finds the most frequently occurring value(s) in an array | mode([1, 2, 2, 3, 3, 3]); // [3] |(x: number, n: number) => number[]
| multiples | | Generate an array of multiples of a number | multiples(2, 5); // [2, 4, 6, 8, 10] |(...numbers: number[]) => number
| multiplication | | Performs multiplication without floating point errors for any number of arguments | multiplication(0.1, 0.2, 0.3); // 0.006 |(n: number, r: number) => number
| nCr | | Calculates combinations (nCr) - number of ways to choose r items from n items | nCr(5, 2); // 10 |(n: number, r: number) => number
| nHr | | Calculates combinations with repetition (nHr) | nHr(5, 2); // 15 |(n: number, r: number) => number
| nPr | | Calculates permutations (nPr) - number of ways to arrange r items from n items | nPr(5, 2); // 20 |(array: number[], percentile: number) => number
| percentile | | Calculate the nth percentile of values in an array | percentile([1, 2, 3, 4, 5], 50); // 3 |(x: number) => Array<{number: number; count: number}>
| primeFactorization | | Performs prime factorization of a number | primeFactorization(12); // [{number: 2, count: 2}, {number: 3, count: 1}] |(x: number, y: number) => number[]
| quotient | | Computes quotient and remainder of division | quotient(5, 2); // [2, 1] |(x: number) => number
| radToDeg | | Converts radians to degrees | radToDeg(Math.PI); // 180 |(max: number, min?: number) => number
| random | | Generates a random integer between min and max (inclusive) | random(10); // returns number between 0 and 10 |(x: number, y: number) => {x: number, y: number, gcd: number}
| reduce | | Reduces a fraction to its lowest terms | reduce(2, 4); // {x: 1, y: 2, gcd: 2} |(n: number, r: number, p: {x: number; y: number}) => number[]
| repeatedTrial | | Calculate probability in repeated trials | repeatedTrial(5, 2, {x: 1/3, y: 2/3}); // [10, 27] |(value: number, precision?: number) => number
| roundOf | | Rounds a number to specified decimal places | roundOf(1.234, 2); // 1.23 |(coefficients: number[][], constants: number[]) => number[]
| solveEquation | | Solves a system of linear equations using Gaussian elimination | solveEquation([[1, 1], [1, 2]], [4, 10]); // [-2, 6] |(values: number[]) => number
| standardDeviation | | Calculates the standard deviation of a set of values | standardDeviation([1, 2, 3]); // 0.816496580927726 |(...numbers: number[]) => number
| subtract | | Performs subtraction with arbitrary number of arguments without floating point errors | subtract(0.1, 0.2); // -0.1 |(value: number, radix?: number) => string
| toBaseN | | Converts a number to a string representation in the specified base | toBaseN(10); // "1010" (binary) |(kelvin: number) => number
| toCelsius | | Converts temperature from Kelvin to Celsius | toCelsius(300); // 26.85 |(celsius: number) => number
| toKelvin | | Converts temperature from Celsius to Kelvin | toKelvin(26.85); // 300 |() => string
| uuidv7 | | Generates a UUID v7 (Universally Unique Identifier version 7) | uuidv7(); // e.g. "018d6e78-e1e5-7c3c-8bf9-ae5942f2ba1c" |(x: number, y: number) => [number, number]
| valueSwap | | Swaps two numbers to ensure x < y | valueSwap(2, 1); // [1, 2] |(state: [number, number, number, number], min?: number, max?: number) => number
| xoshiro256 | | Generates random numbers using the Xoshiro256** algorithm | xoshiro256([1, 2, 3, 4]); // random number between 0 and 1 |
| name | type | description | example |
|------|------|-------------|---------|
| has | | Determines if an object has a specified path | has({ a: { b: 1 } }, "a.b"); // true |(object: Record
| isEmpty | | Checks if an object is empty (has no own properties) | isEmpty({}); // true |
| keyBy | | Creates an object composed of keys generated from the results of running each element of collection through iteratee | keyBy([{id: 1, name: 'a'}, {id: 2, name: 'b'}], 'id'); // {1: {id: 1, name: 'a'}, 2: {id: 2, name: 'b'}} |
| merge | | Merges multiple objects into a single object (shallow merge) | merge({a: 1}, {b: 2}); // {a: 1, b: 2} |
| mergeDeep | | Deeply merges multiple objects into a single object | mergeDeep({a: {b: 1}}, {a: {c: 2}}); // {a: {b: 1, c: 2}} |
| omit | | Creates an object without the specified keys | omit({a: 1, b: 2, c: 3}, 'b'); // {a: 1, c: 3} |
| pick | | Creates a new object with only the specified properties from the source object | pick({ id: 1, name: 'Alice', age: 30 }, 'id', 'name'); // { id: 1, name: 'Alice' } |
| pickDeep | | Creates a new object by deeply selecting properties from the source object based on specified keys | pickDeep({ a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 }, 'a.b.c', 'f'); // { a: { b: { c: 1 } }, f: 4 } |
| name | type | description | example |
|------|------|-------------|---------|
| quickSortSimple | | Quick sort implementation for arrays | quickSort([1, 3, 2, 4, 5], (a, b) => a - b); // [1, 2, 3, 4, 5] |(birthdays: Date \| string \| { year: number; mon: number; day: number }, timeDifference?: HoursTypeInt) => number
| birthdaySimple | | Calculate age from birthdate | birthdaySimple("2000-01-01"); |(properties?: Date \| string \| { year?: number; mon?: T; day?: DayTypeInt
| dayOfWeekSimple | | Get day of the week | dayOfWeekSimple("2000-01-01"); |(timeDifference?: HoursTypeInt \| HoursType) => Date
| nowSimple | | Get current date and time | nowSimple(); // 2021-01-01T00:00:00.000Z |(value: number, averageValue: number[] \| number, standardDeviationValue?: number) => number
| deviationValueSimple | | Calculate deviation score (T-score) | deviationValueSimple(60, 50, 10); // 60 |
| name | type | description | example |
|------|------|-------------|---------|
| camelCase | (str: string) => string | Converts a string to camelCase | camelCase("hello-world"); // "helloWorld" |(string_: string) => string
| deleteSpaces | | Removes all whitespace characters from a string | deleteSpaces("Hello World"); // "HelloWorld" |(str: string) => string
| escapeHtml | | Escapes HTML special characters in a string | escapeHtml(""); // "<script>alert('XSS')</script>" |(template: string, ...values: unknown[]) => string
| formatString | | Replaces placeholders in a template string with specified values | formatString("Hello, {0}!", "World"); // "Hello, World!" |(query: string, items: string[], threshold?: number) => Array<{ item: string; score: number }>
| fuzzySearch | | Perform fuzzy string matching on an array of strings | fuzzySearch("hello", ["hello", "world", "helo", "help"]); // [{ item: "hello", score: 1 }, { item: "helo", score: 0.8 }, { item: "help", score: 0.6 }] |(base64String: string) => string
| fromBase64 | | Converts Base64 to string | fromBase64("SGVsbG8="); // "Hello" |(text: string) => boolean
| hasNoLetters | | Checks if the string contains no letters (contains only emojis, numbers, or special characters) | hasNoLetters("123"); // true |(str: string) => string
| kebabCase | | Converts a string to kebab-case | kebabCase("helloWorld"); // "hello-world" |(string1: string, string2: string) => number
| levenshteinDistance | | Calculates the Levenshtein distance between two strings (minimum number of single-character edits) | levenshteinDistance("kitten", "sitting"); // 3 |(string_: string, targetLength: number, padString: string) => string
| padEnd | | Adds the specified string to the end of the string until it reaches the specified length | padEnd("123", 5, "0"); // "12300" |(string_: string, targetLength: number, padString: string) => string
| padStart | | Pads the start of a string with another string until the target length is reached | padStart("123", 5, "0"); // "00123" |(size?: number, char?: string) => string
| randomString | | Generates a random string | randomString(8); // "aB3dEf9h" |(char?: string) => (size: number) => string
| randomStringInitialization | | Initializes a function that generates random strings | const gen = randomStringInitialization("ABC"); gen(5); // "ABCAB" |(char: string) => string
| reverseString | | Reverses a string | reverseString("Hello"); // "olleH" |(str: string) => string
| slugify | | Convert a string to a URL-friendly slug | slugify("Hello World!"); // "hello-world" |(string1: string, string2: string) => number
| stringSimilarity | | Calculates the similarity between two strings as a percentage (0-1) using Levenshtein distance | stringSimilarity("hello", "hallo"); // 0.8 |(char: string) => string
| toBase64 | | Convert string to Base64 | toBase64("Hello"); // "SGVsbG8=" |(str: string) => string
| toHalfWidth | | Convert full-width characters to half-width characters | toHalfWidth("123ABC"); // "123ABC" |(string_: string, chars: string) => string
| trimCharacters | | Removes specified characters from both ends of a string | trimCharacters("!!!hello!!!", "!"); // "hello" |(string_: string, chars: string) => string
| trimEndCharacters | | Removes specified characters from the end of a string | trimEndCharacters("hello!!!", "!"); // "hello" |(string_: string, chars: string) => string
| trimStartCharacters | | Removes specified characters from the start of a string | trimStartCharacters("!!!hello", "!"); // "hello" |(str: string, length: number, suffix?: string) => string
| truncate | | Truncate a string to a specified length | truncate("Hello World", 5); // "Hello..." |(str: string) => string
| unescapeHtml | | Unescapes HTML entities in a string | unescapeHtml("<script>alert("Hello");</script>"); // "" |
| name | type | description | example |
|------|------|-------------|---------|
| convertTime | (value: string \| number, fromUnit: TimeUnit \| TimeUnitShort, toUnit: TimeUnit \| TimeUnitShort) => number | Converts time between different units | convertTime(1, "hours", "minutes"); // 60 |(unit: TimeUnit \| TimeUnitShort, to: "long" \| "short") => TimeUnit \| TimeUnitShort
| normalizeTimeUnit | | Normalize time unit | normalizeTimeUnit("h", "long"); // "hours" |
| name | type | description | example |
|------|------|-------------|---------|
| createPipeline | | Function that creates a Pipeline instance | createPipeline(1)((x) => x + 1)(); // 2 |
| parseJson | | Parses a JSON string into a typed JavaScript value | parseJson<{a: number}>('{"a": 1}'); // {a: 1} |
| pipe | | Creates a new Pipe instance with an initial value | pipe(1).map(x => x + 1).end(); // 2 |
| name | type | description | example |
|------|------|-------------|---------|
| extractBrowserFromUserAgent | (ua: string) => SimplifiedUserAgentInfoBrowser | Extracts browser information from a User-Agent string | extractBrowserFromUserAgent(navigator.userAgent); // "chrome" |(ua: string) => SimplifiedUserAgentInfoDevice
| extractDeviceFromUserAgent | | Extracts device type information from a User-Agent string | extractDeviceFromUserAgent(navigator.userAgent); // "desktop" |(ua: string) => SimplifiedUserAgentInfoOs
| extractOsFromUserAgent | | Extracts operating system information from a User-Agent string | extractOsFromUserAgent(navigator.userAgent); // "macos" |(userAgent: string) => SimplifiedUserAgentInfo
| parseUserAgent | | Parse a User-Agent string to extract browser, device, and OS information | parseUserAgent(navigator.userAgent); // {browser: "chrome", device: "desktop", os: "macos"} |
| name | type | description | example |
|------|------|-------------|---------|
| unitConverterInitialization | | Unit converter initialization function | const converter = unitConverterInitialization({meters: 1, kilometers: 1000}); converter(5, "kilometers", "meters"); // 5000 |
| name | type | description | example |
|------|------|-------------|---------|
| array | (option?: O, message?: string) => (values: A[]) => ValidateCoreReturnType | Creates an array validator with type-specific validation rules | array()([1, 2, 3]); // {validate: true, message: "", type: [1, 2, 3]} |(message?: string) => (value: boolean) => ValidateCoreReturnType
| boolean | | Creates a boolean validator | boolean()(true); // {validate: true, message: "", type: true} |
| number | | Creates a number validator with optional validation rules | number()(42); // {validate: true, message: "", type: 42} |
| object | | Creates an object validator with property-specific validation rules | object({id: number()})({id: 1}); // {validate: true, message: "", type: {id: 1}} |
| string | | Creates a string validator with optional validation rules | string()("hello"); // {validate: true, message: "", type: "hello"} |
| isArray | | Determines if the value is an array | isArray([1, 2, 3]); // true |() => boolean
| isBrowser | | Determines if the current environment is a browser | isBrowser(); // true in browser |() => boolean
| isBun | | Determines if the current environment is Bun runtime | isBun(); // true in Bun |(a: unknown, b: unknown, options?: IsDeepEqualOptions) => boolean
| isDeepEqual | | Performs deep equality comparison between two values with support for nested objects, arrays, Sets, Maps, and circular references | isDeepEqual({ a: 1, b: [2, 3] }, { b: [2, 3], a: 1 }); // true |
| isDictionaryObject | | Determines if the value is a dictionary-type object | isDictionaryObject({}); // true |
| isDouble | | Determines if the value is a decimal number | isDouble(0.1); // true |(a: unknown, b: unknown) => boolean
| isEqual | | Evaluates true strict equality | isEqual(1, 1); // true |() => boolean
| isNode | | Determines if the current environment is Node.js | isNode(); // true in Node.js |() => boolean
| isNodeWebkit | | Determines if the current environment is Node-Webkit | isNodeWebkit(); // true in Node-Webkit |(object: object) => boolean
| isNotEmpty | | Checks if an object is not empty | isNotEmpty({ a: 1 }); // true |
| isNumber | | Determines if the value represents a number | isNumber(0.1); // true |(number_: number) => boolean
| isPerfectSquare | | Determines if a given integer is a perfect square | isPerfectSquare(16); // true |(n: number) => boolean
| isPrimeNumber | | Determines if a number is prime | isPrimeNumber(17); // true |(value: unknown) => value is string
| isString | | Determines if the value is a string | isString("test"); // true |(value: unknown, loose?: boolean) => boolean
| isValueNaN | | Determines if a value is NaN | isValueNaN(parseInt("not a number")); // true |(email: string, options: ParseEmailOptions) => { valid: boolean; parts?: { local: string; domain: string } }
| parseEmail | | Parses an email address into its local and domain parts | parseEmail("test@example.com", { level: "basic" }); // { valid: true, parts: { local: "test", domain: "example.com" } } |
#### Validate Number Options
| name | type | description | example |
|------|------|-------------|---------|
| double | (message?: string) => ValidateReturnType | Creates a validator for checking if a number is a floating point value | number([double()])(-0.5); // valid |(message?: string) => ValidateReturnType
| even | | Creates a validator for checking if a number is even | number([even()])(4); // valid |(maxValue: number, message?: string) => ValidateReturnType
| maxValue | | Creates a validator for checking if a number is less than or equal to a maximum value | number([maxValue(100)])(50); // valid |(minValue: number, message?: string) => ValidateReturnType
| minValue | | Creates a validator for checking if a number is greater than or equal to a minimum value | number([minValue(0)])(10); // valid |(message?: string) => ValidateReturnType
| odd | | Creates a validator for checking if a number is odd | number([odd()])(3); // valid |(message?: string) => ValidateReturnType
| prime | | Creates a validator for checking if a number is prime | number([prime()])(7); // valid |
#### Validate String Options
| name | type | description | example |
|------|------|-------------|---------|
| validateEmail | (message?: string, options?: ParseEmailOptions) => ValidateReturnType | Creates a validator for checking if a string is a valid email address | string([validateEmail()])("test@example.com"); // valid |(length: number, message?: string) => ValidateReturnType
| length_ | | Creates a validator for checking if a string has an exact length | string([length_(5)])("hello"); // valid |(maxLength: number, message?: string) => ValidateReturnType
| maxLength | | Creates a validator for checking if a string's length is less than or equal to a maximum value | string([maxLength(10)])("hello"); // valid |(minLength: number, message?: string) => ValidateReturnType
| minLength | | Creates a validator for checking if a string's length is greater than or equal to a minimum value | string([minLength(3)])("hello"); // valid |(message?: string) => ValidateReturnType
| numberString | | Creates a validator for checking if a string represents a valid number | string([numberString()])("123.45"); // valid |(pattern: RegExp, message?: string) => ValidateReturnType
| regexMatch | | Creates a validator for checking if a string matches a regular expression pattern | string([regexMatch(/^[A-Z]/)])("Hello"); // valid |(versions?: number[], message?: string) => ValidateReturnType
| uuid | | Creates a validator for checking if a string is a valid UUID | string([uuid()])("550e8400-e29b-41d4-a716-446655440000"); // valid |
| name | type | description | example |
|------|------|-------------|---------|
| OneSecondMs | 1000 | Number of milliseconds in one second | OneSecondMs; // 1000 |60000
| OneMinuteMs | | Number of milliseconds in one minute | OneMinuteMs; // 60000 |3600000
| OneHourMs | | Number of milliseconds in one hour | OneHourMs; // 3600000 |86400000
| OneDayMs | | Number of milliseconds in one day | OneDayMs; // 86400000 |604800000
| OneWeekMs | | Number of milliseconds in one week | OneWeekMs; // 604800000 |2419200000
| OneMonthMs28 | | Number of milliseconds in one month (28 days) | OneMonthMs28; // 2419200000 |2505600000
| OneMonthMs29 | | Number of milliseconds in one month (29 days) | OneMonthMs29; // 2505600000 |2592000000
| OneMonthMs | | Number of milliseconds in one month (30 days) | OneMonthMs; // 2592000000 |2678400000
| OneMonthMs31 | | Number of milliseconds in one month (31 days) | OneMonthMs31; // 2678400000 |31536000000
| OneYearMs | | Number of milliseconds in one year (365 days) | OneYearMs; // 31536000000 |31622400000
| OneYearMs366 | | Number of milliseconds in one year (366 days) | OneYearMs366; // 31622400000 |Object
| HttpStatus | | All HTTP status codes | HttpStatus.OK; // 200 |Object
| HttpInformationalStatus | | HTTP 1xx Informational Status Codes | HttpInformationalStatus.CONTINUE; // 100 |Object
| HttpSuccessStatus | | HTTP 2xx Success Status Codes | HttpSuccessStatus.OK; // 200 |Object
| HttpRedirectionStatus | | HTTP 3xx Redirection Status Codes | HttpRedirectionStatus.MOVED_PERMANENTLY; // 301 |Object
| HttpClientErrorStatus | | HTTP 4xx Client Error Status Codes | HttpClientErrorStatus.NOT_FOUND; // 404 |Object
| HttpServerErrorStatus | | HTTP 5xx Server Error Status Codes | HttpServerErrorStatus.INTERNAL_SERVER_ERROR; // 500` |