UNPKG

ts-prims

Version:
38 lines 1.53 kB
/** Copyright 2025 by Stijn de Witt, some rights reserved */ import { type prim } from './prim.js'; import { type Chars, type chars } from './chars.js'; /** * A variable length string with a maximum length of `N` * * `N` must be a literal positive integer number in the range 0 .. 256. * * This type is meant to model strings with a limited length, such as * SQL's `varchar`. For longer strings, use `memo` if the string length * remains below 64K, or `text` otherwise. * * @see {@link memo} For medium length strings with a maximum of 4K chars * @see {@link Text} For long strings with a maximum of 16M chars * @see {@link clob} For very long strings with a maximum of 4G chars * @see {@link chars} Constraint for short lengths expressed in chars */ export type varchar<N extends Chars> = prim<string, chars<N>>; /** * The prim factory function for `varchar`. * * Returns the prim constructor for `varchar<N>`, based on the given `n`. * * ```ts * type zipcode = varchar<5> * const Zipcode = Varchar(5) * let zip: zipcode = Zipcode('90210') // ok * let oops: zipcode = Zipcode('Too long!') // runtime error * // TypeError: "Too long!" is not of type 'varchar<5>' * ``` * * @param n The max length for the varchar type. * Must be a positive integer number in the range `0` .. `256`. * * @returns The prim type constructor function for `varchar<N>` */ export declare const Varchar: <N extends Chars>(n: N) => import("./prim.js").PrimConstructor<varchar<N>>; //# sourceMappingURL=varchar.d.ts.map