Skip to content

Commit

Permalink
Weak opaque types (#847)
Browse files Browse the repository at this point in the history
* feat: add weak opaque types

* feat: add weak opaque types

* feat: add weak opaque types
  • Loading branch information
belgattitude authored Jan 1, 2024
1 parent e508ebe commit 6b3f2d6
Show file tree
Hide file tree
Showing 37 changed files with 204 additions and 102 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-icons-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@httpx/assert": minor
---

Ass weak opaque type support for primitive types
4 changes: 2 additions & 2 deletions packages/assert/docs/api/modules/array_asserts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### assertArrayNonEmpty

**assertArrayNonEmpty**\<`T`\>(`v`, `msgOrErrorFactory?`): asserts v is ArrayNoNEmpty\<T\>
**assertArrayNonEmpty**\<`T`\>(`v`, `msgOrErrorFactory?`): asserts v is ArrayNonEmpty\<T\>

Assert string is not empty (trims the string by default)

Expand All @@ -31,7 +31,7 @@ Assert string is not empty (trims the string by default)

#### Returns

asserts v is ArrayNoNEmpty\<T\>
asserts v is ArrayNonEmpty\<T\>

**`Throws`**

Expand Down
4 changes: 2 additions & 2 deletions packages/assert/docs/api/modules/array_guards.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### isArrayNonEmpty

**isArrayNonEmpty**\<`T`\>(`v`): v is ArrayNoNEmpty\<T\>
**isArrayNonEmpty**\<`T`\>(`v`): v is ArrayNonEmpty\<T\>

#### Type parameters

Expand All @@ -28,4 +28,4 @@

#### Returns

v is ArrayNoNEmpty\<T\>
v is ArrayNonEmpty\<T\>
12 changes: 6 additions & 6 deletions packages/assert/docs/api/modules/array_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

### Type Aliases

- [ArrayNoNEmpty](array_types.md#arraynonempty)
- [ArrayNonEmpty](array_types.md#arraynonempty)

## Type Aliases

### ArrayNoNEmpty
### ArrayNonEmpty

Ƭ **ArrayNoNEmpty**\<`T`\>: [`T`, ...T[]]
Ƭ **ArrayNonEmpty**\<`T`\>: [`T`, ...T[]]

#### Type parameters

| Name |
| :------ |
| `T` |
| Name | Type |
| :------ | :------ |
| `T` | `unknown` |
4 changes: 2 additions & 2 deletions packages/assert/docs/api/modules/barcode_asserts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### assertEan13

**assertEan13**(`v`, `msgOrErrorFactory?`): asserts v is string
**assertEan13**(`v`, `msgOrErrorFactory?`): asserts v is Ean13

Assert string is not empty (trims the string by default)

Expand All @@ -25,7 +25,7 @@ Assert string is not empty (trims the string by default)

#### Returns

asserts v is string
asserts v is Ean13

**`Throws`**

Expand Down
4 changes: 2 additions & 2 deletions packages/assert/docs/api/modules/barcode_guards.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### isEan13

**isEan13**(`v`): v is string
**isEan13**(`v`): v is Ean13

#### Parameters

Expand All @@ -22,4 +22,4 @@

#### Returns

v is string
v is Ean13
2 changes: 1 addition & 1 deletion packages/assert/docs/api/modules/barcode_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

### Ean13

Ƭ **Ean13**: `string`
Ƭ **Ean13**: `string` & `WeakOpaqueContainer`\<``"Ean13"``\>
6 changes: 3 additions & 3 deletions packages/assert/docs/api/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

### References

- [ArrayNoNEmpty](index.md#arraynonempty)
- [ArrayNonEmpty](index.md#arraynonempty)
- [Ean13](index.md#ean13)
- [NumberSafeInt](index.md#numbersafeint)
- [ParsableSafeInt](index.md#parsablesafeint)
Expand Down Expand Up @@ -53,9 +53,9 @@

## References

### ArrayNoNEmpty
### ArrayNonEmpty

Re-exports [ArrayNoNEmpty](array_types.md#arraynonempty)
Re-exports [ArrayNonEmpty](array_types.md#arraynonempty)

___

Expand Down
4 changes: 2 additions & 2 deletions packages/assert/docs/api/modules/number_asserts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### assertNumberSafeInt

**assertNumberSafeInt**(`v`, `msgOrErrorFactory?`): asserts v is number
**assertNumberSafeInt**(`v`, `msgOrErrorFactory?`): asserts v is NumberSafeInt

Assert string is not empty (trims the string by default)

Expand All @@ -25,7 +25,7 @@ Assert string is not empty (trims the string by default)

#### Returns

asserts v is number
asserts v is NumberSafeInt

**`Throws`**

Expand Down
4 changes: 2 additions & 2 deletions packages/assert/docs/api/modules/number_guards.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### isNumberSafeInt

**isNumberSafeInt**\<`T`\>(`v`): v is ArrayNoNEmpty\<T\>
**isNumberSafeInt**\<`T`\>(`v`): v is ArrayNonEmpty\<T\>

#### Type parameters

Expand All @@ -28,4 +28,4 @@

#### Returns

v is ArrayNoNEmpty\<T\>
v is ArrayNonEmpty\<T\>
2 changes: 1 addition & 1 deletion packages/assert/docs/api/modules/number_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

### NumberSafeInt

Ƭ **NumberSafeInt**: `number`
Ƭ **NumberSafeInt**: `number` & `WeakOpaqueContainer`\<``"NumberSafeInt"``\>
4 changes: 2 additions & 2 deletions packages/assert/docs/api/modules/object_asserts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### assertPlainObject

**assertPlainObject**(`v`, `msgOrErrorFactory?`): asserts v is string
**assertPlainObject**(`v`, `msgOrErrorFactory?`): asserts v is PlainObject

Assert a value is a plain object

Expand All @@ -25,7 +25,7 @@ Assert a value is a plain object

#### Returns

asserts v is string
asserts v is PlainObject

**`Throws`**

Expand Down
8 changes: 4 additions & 4 deletions packages/assert/docs/api/modules/string_asserts.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

### assertParsableSafeInt

**assertParsableSafeInt**(`v`, `msgOrErrorFactory?`): asserts v is string
**assertParsableSafeInt**(`v`, `msgOrErrorFactory?`): asserts v is ParsableSafeInt

#### Parameters

Expand All @@ -25,13 +25,13 @@

#### Returns

asserts v is string
asserts v is ParsableSafeInt

___

### assertParsableStrictIsoDateZ

**assertParsableStrictIsoDateZ**(`v`, `msgOrErrorFactory?`): asserts v is string
**assertParsableStrictIsoDateZ**(`v`, `msgOrErrorFactory?`): asserts v is ParsableStrictIsoDateZ

#### Parameters

Expand All @@ -42,7 +42,7 @@ ___

#### Returns

asserts v is string
asserts v is ParsableStrictIsoDateZ

**`Throws`**

Expand Down
12 changes: 6 additions & 6 deletions packages/assert/docs/api/modules/string_guards.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

### isParsableSafeInt

**isParsableSafeInt**(`v`): v is string
**isParsableSafeInt**(`v`): v is ParsableSafeInt

#### Parameters

Expand All @@ -24,13 +24,13 @@

#### Returns

v is string
v is ParsableSafeInt

___

### isParsableStrictIsoDateZ

**isParsableStrictIsoDateZ**(`v`): v is string
**isParsableStrictIsoDateZ**(`v`): v is ParsableStrictIsoDateZ

Checks if the value is a string containing a valid ISO-8601 date time
with microseconds that ends with 'z' representing UTC+0 timezone (aka zulu time).
Expand All @@ -48,7 +48,7 @@ isStrParsableIsoDateZ('2023-12-29T23:37:31.653z')

#### Returns

v is string
v is ParsableStrictIsoDateZ

**`Link`**

Expand All @@ -66,7 +66,7 @@ ___

### isStringNonEmpty

**isStringNonEmpty**(`v`): v is string
**isStringNonEmpty**(`v`): v is StringNonEmpty

#### Parameters

Expand All @@ -76,4 +76,4 @@ ___

#### Returns

v is string
v is StringNonEmpty
6 changes: 3 additions & 3 deletions packages/assert/docs/api/modules/string_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

### ParsableSafeInt

Ƭ **ParsableSafeInt**: `string`
Ƭ **ParsableSafeInt**: `string` & `WeakOpaqueContainer`\<``"ParsableSafeInt"``\>

___

### ParsableStrictIsoDateZ

Ƭ **ParsableStrictIsoDateZ**: `string`
Ƭ **ParsableStrictIsoDateZ**: `string` & `WeakOpaqueContainer`\<``"ParsableStrictIsoDateZ"``\>

___

### StringNonEmpty

Ƭ **StringNonEmpty**: `string`
Ƭ **StringNonEmpty**: `string` & `WeakOpaqueContainer`\<``"ParsableStrictIsoDateZ"``\>
20 changes: 10 additions & 10 deletions packages/assert/docs/api/modules/uuid_asserts.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

### assertUuid

**assertUuid**(`v`, `msgOrErrorFactory?`, `options?`): asserts v is string
**assertUuid**(`v`, `msgOrErrorFactory?`, `options?`): asserts v is Uuid

Asserts a value is a valid uuid v1, v3, v4 or v5
Accept optional version
Expand All @@ -32,7 +32,7 @@ Accept optional version

#### Returns

asserts v is string
asserts v is Uuid

**`Throws`**

Expand All @@ -42,7 +42,7 @@ ___

### assertUuidV1

**assertUuidV1**(`v`, `msgOrErrorFactory?`): asserts v is string
**assertUuidV1**(`v`, `msgOrErrorFactory?`): asserts v is UuidV1

Asserts a value is a valid uuid v1

Expand All @@ -55,7 +55,7 @@ Asserts a value is a valid uuid v1

#### Returns

asserts v is string
asserts v is UuidV1

**`Throws`**

Expand All @@ -65,7 +65,7 @@ ___

### assertUuidV3

**assertUuidV3**(`v`, `msgOrErrorFactory?`): asserts v is string
**assertUuidV3**(`v`, `msgOrErrorFactory?`): asserts v is UuidV3

Asserts a value is a valid uuid v3

Expand All @@ -78,7 +78,7 @@ Asserts a value is a valid uuid v3

#### Returns

asserts v is string
asserts v is UuidV3

**`Throws`**

Expand All @@ -88,7 +88,7 @@ ___

### assertUuidV4

**assertUuidV4**(`v`, `msgOrErrorFactory?`): asserts v is string
**assertUuidV4**(`v`, `msgOrErrorFactory?`): asserts v is UuidV4

Assert a value is a valid uuid v4

Expand All @@ -101,7 +101,7 @@ Assert a value is a valid uuid v4

#### Returns

asserts v is string
asserts v is UuidV4

**`Throws`**

Expand All @@ -111,7 +111,7 @@ ___

### assertUuidV5

**assertUuidV5**(`v`, `msgOrErrorFactory?`): asserts v is string
**assertUuidV5**(`v`, `msgOrErrorFactory?`): asserts v is UuidV5

Assert a value is a valid uuid v5

Expand All @@ -124,7 +124,7 @@ Assert a value is a valid uuid v5

#### Returns

asserts v is string
asserts v is UuidV5

**`Throws`**

Expand Down
Loading

0 comments on commit 6b3f2d6

Please sign in to comment.