UNPKG

2.41 kBTypeScriptView Raw
1import type { Arbitrary } from '../check/arbitrary/definition/Arbitrary.js';
2import type { StringSharedConstraints } from './_shared/StringSharedConstraints.js';
3export type { StringSharedConstraints } from './_shared/StringSharedConstraints.js';
4/**
5 * Constraints to be applied on arbitrary {@link string}
6 * @remarks Since 3.22.0
7 * @public
8 */
9export type StringConstraints = StringSharedConstraints & {
10 /**
11 * A string results from the join between several unitary strings produced by the Arbitrary instance defined by `unit`.
12 * The `minLength` and `maxLength` refers to the number of these units composing the string. In other words it does not have to be confound with `.length` on an instance of string.
13 *
14 * A unit can either be a fully custom Arbitrary or one of the pre-defined options:
15 * - `'grapheme'` - Any printable grapheme as defined by the Unicode standard. This unit includes graphemes that may:
16 * - Span multiple code points (e.g., `'\u{0061}\u{0300}'`)
17 * - Consist of multiple characters (e.g., `'\u{1f431}'`)
18 * - Include non-European and non-ASCII characters.
19 * - **Note:** Graphemes produced by this unit are designed to remain visually distinct when joined together.
20 * - `'grapheme-composite'` - Any printable grapheme limited to a single code point. This option produces graphemes limited to a single code point.
21 * - **Note:** Graphemes produced by this unit are designed to remain visually distinct when joined together.
22 * - `'grapheme-ascii'` - Any printable ASCII character.
23 * - `'binary'` - Any possible code point (except half surrogate pairs), regardless of how it may combine with subsequent code points in the produced string. This unit produces a single code point within the full Unicode range (0000-10FFFF).
24 * - `'binary-ascii'` - Any possible ASCII character, including control characters. This unit produces any code point in the range 0000-00FF.
25 *
26 * @defaultValue 'grapheme-ascii'
27 * @remarks Since 3.22.0
28 */
29 unit?: 'grapheme' | 'grapheme-composite' | 'grapheme-ascii' | 'binary' | 'binary-ascii' | Arbitrary<string>;
30};
31/**
32 * For strings of {@link char}
33 *
34 * @param constraints - Constraints to apply when building instances (since 2.4.0)
35 *
36 * @remarks Since 0.0.1
37 * @public
38 */
39export declare function string(constraints?: StringConstraints): Arbitrary<string>;