@augment-vir/assert 30.0.0 → 30.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +11 -0
  2. package/dist/assertions/boolean.d.ts +443 -17
  3. package/dist/assertions/boolean.js +365 -8
  4. package/dist/assertions/boundary.d.ts +657 -13
  5. package/dist/assertions/boundary.js +537 -5
  6. package/dist/assertions/enum.d.ts +236 -8
  7. package/dist/assertions/enum.js +197 -5
  8. package/dist/assertions/equality/entry-equality.d.ts +287 -11
  9. package/dist/assertions/equality/entry-equality.js +243 -6
  10. package/dist/assertions/equality/json-equality.d.ts +244 -15
  11. package/dist/assertions/equality/json-equality.js +207 -11
  12. package/dist/assertions/equality/simple-equality.d.ts +849 -28
  13. package/dist/assertions/equality/simple-equality.js +712 -6
  14. package/dist/assertions/equality/ts-type-equality.d.ts +37 -1
  15. package/dist/assertions/equality/ts-type-equality.js +13 -1
  16. package/dist/assertions/extendable-assertions.d.ts +288 -120
  17. package/dist/assertions/extendable-assertions.js +32 -60
  18. package/dist/assertions/http.d.ts +217 -10
  19. package/dist/assertions/http.js +182 -6
  20. package/dist/assertions/instance.d.ts +189 -8
  21. package/dist/assertions/instance.js +159 -5
  22. package/dist/assertions/keys.d.ts +658 -13
  23. package/dist/assertions/keys.js +556 -5
  24. package/dist/assertions/length.d.ts +381 -9
  25. package/dist/assertions/length.js +309 -5
  26. package/dist/assertions/nullish.d.ts +169 -7
  27. package/dist/assertions/nullish.js +137 -6
  28. package/dist/assertions/numeric.d.ts +965 -11
  29. package/dist/assertions/numeric.js +819 -1
  30. package/dist/assertions/output.d.ts +107 -7
  31. package/dist/assertions/output.js +92 -5
  32. package/dist/assertions/primitive.d.ts +416 -13
  33. package/dist/assertions/primitive.js +352 -6
  34. package/dist/assertions/promise.d.ts +640 -21
  35. package/dist/assertions/promise.js +536 -15
  36. package/dist/assertions/regexp.d.ts +202 -3
  37. package/dist/assertions/regexp.js +173 -1
  38. package/dist/assertions/runtime-type.d.ts +1822 -41
  39. package/dist/assertions/runtime-type.js +1558 -35
  40. package/dist/assertions/throws.d.ts +265 -17
  41. package/dist/assertions/throws.js +229 -17
  42. package/dist/assertions/uuid.d.ts +233 -10
  43. package/dist/assertions/uuid.js +195 -6
  44. package/dist/assertions/values.d.ts +1086 -15
  45. package/dist/assertions/values.js +907 -6
  46. package/dist/augments/assertion.error.d.ts +2 -1
  47. package/dist/augments/assertion.error.js +2 -1
  48. package/dist/augments/guards/assert-wrap.d.ts +82 -37
  49. package/dist/augments/guards/assert-wrap.js +13 -2
  50. package/dist/augments/guards/assert.d.ts +30 -14
  51. package/dist/augments/guards/assert.js +21 -4
  52. package/dist/augments/guards/check-wrap.d.ts +94 -51
  53. package/dist/augments/guards/check-wrap.js +11 -3
  54. package/dist/augments/guards/check.d.ts +87 -37
  55. package/dist/augments/guards/check.js +9 -2
  56. package/dist/augments/guards/wait-until.d.ts +110 -103
  57. package/dist/augments/guards/wait-until.js +18 -3
  58. package/dist/augments/if-equals.d.ts +4 -2
  59. package/dist/guard-types/assert-wrap-function.d.ts +5 -2
  60. package/dist/guard-types/check-function.d.ts +5 -2
  61. package/dist/guard-types/check-wrap-wrapper-function.d.ts +4 -1
  62. package/dist/guard-types/guard-group.d.ts +7 -8
  63. package/dist/guard-types/wait-until-function.d.ts +8 -3
  64. package/dist/guard-types/wait-until-function.js +1 -1
  65. package/package.json +21 -8
@@ -1,34 +1,257 @@
1
1
  import { MaybePromise, Uuid } from '@augment-vir/core';
2
+ import { autoGuardSymbol } from '../guard-types/guard-override.js';
2
3
  import { WaitUntilOptions } from '../guard-types/wait-until-function.js';
3
4
  /** Checks if the input string is a valid v4 UUID. */
4
5
  declare function isUuid(actual: unknown, failureMessage?: string | undefined): asserts actual is Uuid;
5
6
  declare function isNotUuid<const Actual>(actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, Uuid>;
6
7
  export declare const uuidGuards: {
7
- assertions: {
8
+ assert: {
8
9
  /**
9
- * Check if the given string is a valid UUID. This supports UUID versions 1-8 and does _not_
10
- * support the Nil UUID (all zeros) or the Max UUID (all Fs).
10
+ * Asserts that a value is a valid UUID. Does not accept the nil or max UUIDs.
11
11
  *
12
- * Type guards the input.
12
+ * Type guards the value.
13
+ *
14
+ * @example
15
+ *
16
+ * ```ts
17
+ * import {assert} from '@augment-vir/assert';
18
+ * import {createUuidV4} from '@augment-vir/common';
19
+ *
20
+ * assert.isUuid(createUuidV4()); // passes
21
+ * assert.isUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // passes
22
+ * assert.isUuid('00000000-0000-0000-0000-000000000000'); // fails
23
+ * assert.isUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // fails
24
+ * assert.isUuid('not-a-uuid'); // fails
25
+ * ```
26
+ *
27
+ * @throws {@link AssertionError} If the assertion fails.
28
+ * @see
29
+ * - {@link assert.isNotUuid} : the opposite assertion.
13
30
  */
14
31
  isUuid: typeof isUuid;
15
32
  /**
16
- * Check if the given string is _not_ a valid UUID.
33
+ * Asserts that a value is _not_ a valid UUID. The nil or max UUIDs are included as _not_ valid.
34
+ *
35
+ * Type guards the value.
36
+ *
37
+ * @example
38
+ *
39
+ * ```ts
40
+ * import {assert} from '@augment-vir/assert';
41
+ * import {createUuidV4} from '@augment-vir/common';
42
+ *
43
+ * assert.isNotUuid(createUuidV4()); // fails
44
+ * assert.isNotUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // fails
45
+ * assert.isNotUuid('00000000-0000-0000-0000-000000000000'); // passes
46
+ * assert.isNotUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // passes
47
+ * assert.isNotUuid('not-a-uuid'); // passes
48
+ * ```
17
49
  *
18
- * Type guards the input.
50
+ * @throws {@link AssertionError} If the assertion fails.
51
+ * @see
52
+ * - {@link assert.isUuid} : the opposite assertion.
19
53
  */
20
54
  isNotUuid: typeof isNotUuid;
21
55
  };
22
- checkOverrides: {
56
+ check: {
57
+ /**
58
+ * Checks that a value is a valid UUID. Does not accept the nil or max UUIDs.
59
+ *
60
+ * Type guards the value.
61
+ *
62
+ * @example
63
+ *
64
+ * ```ts
65
+ * import {check} from '@augment-vir/assert';
66
+ * import {createUuidV4} from '@augment-vir/common';
67
+ *
68
+ * check.isUuid(createUuidV4()); // returns `true`
69
+ * check.isUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `true`
70
+ * check.isUuid('00000000-0000-0000-0000-000000000000'); // returns `false`
71
+ * check.isUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `false`
72
+ * check.isUuid('not-a-uuid'); // returns `false`
73
+ * ```
74
+ *
75
+ * @see
76
+ * - {@link check.isNotUuid} : the opposite check.
77
+ */
78
+ isUuid: typeof autoGuardSymbol;
79
+ /**
80
+ * Checks that a value is _not_ a valid UUID. The nil or max UUIDs are included as _not_
81
+ * valid.
82
+ *
83
+ * Type guards the value.
84
+ *
85
+ * @example
86
+ *
87
+ * ```ts
88
+ * import {check} from '@augment-vir/assert';
89
+ * import {createUuidV4} from '@augment-vir/common';
90
+ *
91
+ * check.isNotUuid(createUuidV4()); // returns `false`
92
+ * check.isNotUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `false`
93
+ * check.isNotUuid('00000000-0000-0000-0000-000000000000'); // returns `true`
94
+ * check.isNotUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `true`
95
+ * check.isNotUuid('not-a-uuid'); // returns `true`
96
+ * ```
97
+ *
98
+ * @see
99
+ * - {@link check.isUuid} : the opposite check.
100
+ */
23
101
  isNotUuid: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, Uuid>;
24
102
  };
25
- assertWrapOverrides: {
103
+ assertWrap: {
104
+ /**
105
+ * Asserts that a value is a valid UUID. Does not accept the nil or max UUIDs. Returns the
106
+ * value if the assertion passes.
107
+ *
108
+ * Type guards the value.
109
+ *
110
+ * @example
111
+ *
112
+ * ```ts
113
+ * import {assertWrap} from '@augment-vir/assert';
114
+ * import {createUuidV4} from '@augment-vir/common';
115
+ *
116
+ * assertWrap.isUuid(createUuidV4()); // returns the generated UUID
117
+ * assertWrap.isUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `'29e0f18e-6115-4982-8342-0afcadf5d611'`
118
+ * assertWrap.isUuid('00000000-0000-0000-0000-000000000000'); // throws an error
119
+ * assertWrap.isUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // throws an error
120
+ * assertWrap.isUuid('not-a-uuid'); // throws an error
121
+ * ```
122
+ *
123
+ * @throws {@link AssertionError} If the assertion fails.
124
+ * @see
125
+ * - {@link assertWrap.isNotUuid} : the opposite assertion.
126
+ */
127
+ isUuid: typeof autoGuardSymbol;
128
+ /**
129
+ * Asserts that a value is _not_ a valid UUID. The nil or max UUIDs are included as _not_
130
+ * valid. Returns the value if the assertion passes.
131
+ *
132
+ * Type guards the value.
133
+ *
134
+ * @example
135
+ *
136
+ * ```ts
137
+ * import {assertWrap} from '@augment-vir/assert';
138
+ * import {createUuidV4} from '@augment-vir/common';
139
+ *
140
+ * assertWrap.isNotUuid(createUuidV4()); // throws an error
141
+ * assertWrap.isNotUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // throws an error
142
+ * assertWrap.isNotUuid('00000000-0000-0000-0000-000000000000'); // returns `'00000000-0000-0000-0000-000000000000'`
143
+ * assertWrap.isNotUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'`
144
+ * assertWrap.isNotUuid('not-a-uuid'); // returns `'not-a-uuid'`
145
+ * ```
146
+ *
147
+ * @throws {@link AssertionError} If the assertion fails.
148
+ * @see
149
+ * - {@link assertWrap.isUuid} : the opposite assertion.
150
+ */
26
151
  isNotUuid: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, Uuid>;
27
152
  };
28
- checkWrapOverrides: {
153
+ checkWrap: {
154
+ /**
155
+ * Checks that a value is a valid UUID. Does not accept the nil or max UUIDs. Returns the
156
+ * value if the check passes, otherwise `undefined`.
157
+ *
158
+ * Type guards the value.
159
+ *
160
+ * @example
161
+ *
162
+ * ```ts
163
+ * import {checkWrap} from '@augment-vir/assert';
164
+ * import {createUuidV4} from '@augment-vir/common';
165
+ *
166
+ * checkWrap.isUuid(createUuidV4()); // returns the generated UUID
167
+ * checkWrap.isUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `'29e0f18e-6115-4982-8342-0afcadf5d611'`
168
+ * checkWrap.isUuid('00000000-0000-0000-0000-000000000000'); // returns `undefined`
169
+ * checkWrap.isUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `undefined`
170
+ * checkWrap.isUuid('not-a-uuid'); // returns `undefined`
171
+ * ```
172
+ *
173
+ * @returns The value if the check passes, otherwise `undefined`.
174
+ * @see
175
+ * - {@link checkWrap.isNotUuid} : the opposite check.
176
+ */
177
+ isUuid: typeof autoGuardSymbol;
178
+ /**
179
+ * Checks that a value is _not_ a valid UUID. The nil or max UUIDs are included as _not_
180
+ * valid. Returns the value if the check passes, otherwise `undefined`.
181
+ *
182
+ * Type guards the value.
183
+ *
184
+ * @example
185
+ *
186
+ * ```ts
187
+ * import {checkWrap} from '@augment-vir/assert';
188
+ * import {createUuidV4} from '@augment-vir/common';
189
+ *
190
+ * checkWrap.isNotUuid(createUuidV4()); // returns `undefined`
191
+ * checkWrap.isNotUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `undefined`
192
+ * checkWrap.isNotUuid('00000000-0000-0000-0000-000000000000'); // returns `'00000000-0000-0000-0000-000000000000'`
193
+ * checkWrap.isNotUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'`
194
+ * checkWrap.isNotUuid('not-a-uuid'); // returns `'not-a-uuid'`
195
+ * ```
196
+ *
197
+ * @returns The value if the check passes, otherwise `undefined`.
198
+ * @see
199
+ * - {@link checkWrap.isUuid} : the opposite check.
200
+ */
29
201
  isNotUuid: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, Uuid> | undefined;
30
202
  };
31
- waitUntilOverrides: {
203
+ waitUntil: {
204
+ /**
205
+ * Repeatedly calls a callback until its output is a valid UUID. Does not accept the nil or
206
+ * max UUIDs. Returns the value if the assertion passes. Once the callback output passes, it
207
+ * is returned. If the attempts time out, an error is thrown.
208
+ *
209
+ * Type guards the value.
210
+ *
211
+ * @example
212
+ *
213
+ * ```ts
214
+ * import {waitUntil} from '@augment-vir/assert';
215
+ * import {createUuidV4} from '@augment-vir/common';
216
+ *
217
+ * await waitUntil.isUuid(() => createUuidV4()); // returns the generated value
218
+ * await waitUntil.isUuid(() => '29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `'29e0f18e-6115-4982-8342-0afcadf5d611'`
219
+ * await waitUntil.isUuid(() => '00000000-0000-0000-0000-000000000000'); // throws an error
220
+ * await waitUntil.isUuid(() => 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // throws an error
221
+ * await waitUntil.isUuid(() => 'not-a-uuid'); // throws an error
222
+ * ```
223
+ *
224
+ * @returns The callback output once it passes.
225
+ * @throws {@link AssertionError} On timeout.
226
+ * @see
227
+ * - {@link waitUntil.isNotUuid} : the opposite assertion.
228
+ */
229
+ isUuid: typeof autoGuardSymbol;
230
+ /**
231
+ * Repeatedly calls a callback until its output is _not_ a valid UUID. The nil or max UUIDs
232
+ * are included as _not_ valid. Returns the value if the assertion passes. Once the callback
233
+ * output passes, it is returned. If the attempts time out, an error is thrown.
234
+ *
235
+ * Type guards the value.
236
+ *
237
+ * @example
238
+ *
239
+ * ```ts
240
+ * import {waitUntil} from '@augment-vir/assert';
241
+ * import {createUuidV4} from '@augment-vir/common';
242
+ *
243
+ * await waitUntil.isNotUuid(() => createUuidV4()); // throws an error
244
+ * await waitUntil.isNotUuid(() => '29e0f18e-6115-4982-8342-0afcadf5d611'); // throws an error
245
+ * await waitUntil.isNotUuid(() => '00000000-0000-0000-0000-000000000000'); // returns `'00000000-0000-0000-0000-000000000000'`
246
+ * await waitUntil.isNotUuid(() => 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'`
247
+ * await waitUntil.isNotUuid(() => 'not-a-uuid'); // returns `'not-a-uuid'`
248
+ * ```
249
+ *
250
+ * @returns The callback output once it passes.
251
+ * @throws {@link AssertionError} On timeout.
252
+ * @see
253
+ * - {@link waitUntil.isUuid} : the opposite assertion.
254
+ */
32
255
  isNotUuid: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, Uuid>>;
33
256
  };
34
257
  };
@@ -1,5 +1,5 @@
1
1
  import { AssertionError } from '../augments/assertion.error.js';
2
- import { autoGuard } from '../guard-types/guard-override.js';
2
+ import { autoGuard, autoGuardSymbol } from '../guard-types/guard-override.js';
3
3
  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
4
4
  /** Checks if the input string is a valid v4 UUID. */
5
5
  function isUuid(actual, failureMessage) {
@@ -17,17 +17,206 @@ const assertions = {
17
17
  isNotUuid,
18
18
  };
19
19
  export const uuidGuards = {
20
- assertions,
21
- checkOverrides: {
20
+ assert: assertions,
21
+ check: {
22
+ /**
23
+ * Checks that a value is a valid UUID. Does not accept the nil or max UUIDs.
24
+ *
25
+ * Type guards the value.
26
+ *
27
+ * @example
28
+ *
29
+ * ```ts
30
+ * import {check} from '@augment-vir/assert';
31
+ * import {createUuidV4} from '@augment-vir/common';
32
+ *
33
+ * check.isUuid(createUuidV4()); // returns `true`
34
+ * check.isUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `true`
35
+ * check.isUuid('00000000-0000-0000-0000-000000000000'); // returns `false`
36
+ * check.isUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `false`
37
+ * check.isUuid('not-a-uuid'); // returns `false`
38
+ * ```
39
+ *
40
+ * @see
41
+ * - {@link check.isNotUuid} : the opposite check.
42
+ */
43
+ isUuid: autoGuardSymbol,
44
+ /**
45
+ * Checks that a value is _not_ a valid UUID. The nil or max UUIDs are included as _not_
46
+ * valid.
47
+ *
48
+ * Type guards the value.
49
+ *
50
+ * @example
51
+ *
52
+ * ```ts
53
+ * import {check} from '@augment-vir/assert';
54
+ * import {createUuidV4} from '@augment-vir/common';
55
+ *
56
+ * check.isNotUuid(createUuidV4()); // returns `false`
57
+ * check.isNotUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `false`
58
+ * check.isNotUuid('00000000-0000-0000-0000-000000000000'); // returns `true`
59
+ * check.isNotUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `true`
60
+ * check.isNotUuid('not-a-uuid'); // returns `true`
61
+ * ```
62
+ *
63
+ * @see
64
+ * - {@link check.isUuid} : the opposite check.
65
+ */
22
66
  isNotUuid: autoGuard(),
23
67
  },
24
- assertWrapOverrides: {
68
+ assertWrap: {
69
+ /**
70
+ * Asserts that a value is a valid UUID. Does not accept the nil or max UUIDs. Returns the
71
+ * value if the assertion passes.
72
+ *
73
+ * Type guards the value.
74
+ *
75
+ * @example
76
+ *
77
+ * ```ts
78
+ * import {assertWrap} from '@augment-vir/assert';
79
+ * import {createUuidV4} from '@augment-vir/common';
80
+ *
81
+ * assertWrap.isUuid(createUuidV4()); // returns the generated UUID
82
+ * assertWrap.isUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `'29e0f18e-6115-4982-8342-0afcadf5d611'`
83
+ * assertWrap.isUuid('00000000-0000-0000-0000-000000000000'); // throws an error
84
+ * assertWrap.isUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // throws an error
85
+ * assertWrap.isUuid('not-a-uuid'); // throws an error
86
+ * ```
87
+ *
88
+ * @throws {@link AssertionError} If the assertion fails.
89
+ * @see
90
+ * - {@link assertWrap.isNotUuid} : the opposite assertion.
91
+ */
92
+ isUuid: autoGuardSymbol,
93
+ /**
94
+ * Asserts that a value is _not_ a valid UUID. The nil or max UUIDs are included as _not_
95
+ * valid. Returns the value if the assertion passes.
96
+ *
97
+ * Type guards the value.
98
+ *
99
+ * @example
100
+ *
101
+ * ```ts
102
+ * import {assertWrap} from '@augment-vir/assert';
103
+ * import {createUuidV4} from '@augment-vir/common';
104
+ *
105
+ * assertWrap.isNotUuid(createUuidV4()); // throws an error
106
+ * assertWrap.isNotUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // throws an error
107
+ * assertWrap.isNotUuid('00000000-0000-0000-0000-000000000000'); // returns `'00000000-0000-0000-0000-000000000000'`
108
+ * assertWrap.isNotUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'`
109
+ * assertWrap.isNotUuid('not-a-uuid'); // returns `'not-a-uuid'`
110
+ * ```
111
+ *
112
+ * @throws {@link AssertionError} If the assertion fails.
113
+ * @see
114
+ * - {@link assertWrap.isUuid} : the opposite assertion.
115
+ */
25
116
  isNotUuid: autoGuard(),
26
117
  },
27
- checkWrapOverrides: {
118
+ checkWrap: {
119
+ /**
120
+ * Checks that a value is a valid UUID. Does not accept the nil or max UUIDs. Returns the
121
+ * value if the check passes, otherwise `undefined`.
122
+ *
123
+ * Type guards the value.
124
+ *
125
+ * @example
126
+ *
127
+ * ```ts
128
+ * import {checkWrap} from '@augment-vir/assert';
129
+ * import {createUuidV4} from '@augment-vir/common';
130
+ *
131
+ * checkWrap.isUuid(createUuidV4()); // returns the generated UUID
132
+ * checkWrap.isUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `'29e0f18e-6115-4982-8342-0afcadf5d611'`
133
+ * checkWrap.isUuid('00000000-0000-0000-0000-000000000000'); // returns `undefined`
134
+ * checkWrap.isUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `undefined`
135
+ * checkWrap.isUuid('not-a-uuid'); // returns `undefined`
136
+ * ```
137
+ *
138
+ * @returns The value if the check passes, otherwise `undefined`.
139
+ * @see
140
+ * - {@link checkWrap.isNotUuid} : the opposite check.
141
+ */
142
+ isUuid: autoGuardSymbol,
143
+ /**
144
+ * Checks that a value is _not_ a valid UUID. The nil or max UUIDs are included as _not_
145
+ * valid. Returns the value if the check passes, otherwise `undefined`.
146
+ *
147
+ * Type guards the value.
148
+ *
149
+ * @example
150
+ *
151
+ * ```ts
152
+ * import {checkWrap} from '@augment-vir/assert';
153
+ * import {createUuidV4} from '@augment-vir/common';
154
+ *
155
+ * checkWrap.isNotUuid(createUuidV4()); // returns `undefined`
156
+ * checkWrap.isNotUuid('29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `undefined`
157
+ * checkWrap.isNotUuid('00000000-0000-0000-0000-000000000000'); // returns `'00000000-0000-0000-0000-000000000000'`
158
+ * checkWrap.isNotUuid('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'`
159
+ * checkWrap.isNotUuid('not-a-uuid'); // returns `'not-a-uuid'`
160
+ * ```
161
+ *
162
+ * @returns The value if the check passes, otherwise `undefined`.
163
+ * @see
164
+ * - {@link checkWrap.isUuid} : the opposite check.
165
+ */
28
166
  isNotUuid: autoGuard(),
29
167
  },
30
- waitUntilOverrides: {
168
+ waitUntil: {
169
+ /**
170
+ * Repeatedly calls a callback until its output is a valid UUID. Does not accept the nil or
171
+ * max UUIDs. Returns the value if the assertion passes. Once the callback output passes, it
172
+ * is returned. If the attempts time out, an error is thrown.
173
+ *
174
+ * Type guards the value.
175
+ *
176
+ * @example
177
+ *
178
+ * ```ts
179
+ * import {waitUntil} from '@augment-vir/assert';
180
+ * import {createUuidV4} from '@augment-vir/common';
181
+ *
182
+ * await waitUntil.isUuid(() => createUuidV4()); // returns the generated value
183
+ * await waitUntil.isUuid(() => '29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `'29e0f18e-6115-4982-8342-0afcadf5d611'`
184
+ * await waitUntil.isUuid(() => '00000000-0000-0000-0000-000000000000'); // throws an error
185
+ * await waitUntil.isUuid(() => 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // throws an error
186
+ * await waitUntil.isUuid(() => 'not-a-uuid'); // throws an error
187
+ * ```
188
+ *
189
+ * @returns The callback output once it passes.
190
+ * @throws {@link AssertionError} On timeout.
191
+ * @see
192
+ * - {@link waitUntil.isNotUuid} : the opposite assertion.
193
+ */
194
+ isUuid: autoGuardSymbol,
195
+ /**
196
+ * Repeatedly calls a callback until its output is _not_ a valid UUID. The nil or max UUIDs
197
+ * are included as _not_ valid. Returns the value if the assertion passes. Once the callback
198
+ * output passes, it is returned. If the attempts time out, an error is thrown.
199
+ *
200
+ * Type guards the value.
201
+ *
202
+ * @example
203
+ *
204
+ * ```ts
205
+ * import {waitUntil} from '@augment-vir/assert';
206
+ * import {createUuidV4} from '@augment-vir/common';
207
+ *
208
+ * await waitUntil.isNotUuid(() => createUuidV4()); // throws an error
209
+ * await waitUntil.isNotUuid(() => '29e0f18e-6115-4982-8342-0afcadf5d611'); // throws an error
210
+ * await waitUntil.isNotUuid(() => '00000000-0000-0000-0000-000000000000'); // returns `'00000000-0000-0000-0000-000000000000'`
211
+ * await waitUntil.isNotUuid(() => 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'`
212
+ * await waitUntil.isNotUuid(() => 'not-a-uuid'); // returns `'not-a-uuid'`
213
+ * ```
214
+ *
215
+ * @returns The callback output once it passes.
216
+ * @throws {@link AssertionError} On timeout.
217
+ * @see
218
+ * - {@link waitUntil.isUuid} : the opposite assertion.
219
+ */
31
220
  isNotUuid: autoGuard(),
32
221
  },
33
222
  };