Skip to content

Commit c073f60

Browse files
committed
fix(TObjectOfShape): Use direct object types
1 parent 458c9b2 commit c073f60

File tree

4 files changed

+44
-44
lines changed

4 files changed

+44
-44
lines changed

docs/classes/Guard.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ An abstract class, which is the parent class of all Guards. (Names starting with
4747

4848
#### Defined in
4949

50-
[src/Guard.ts:11](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/Guard.ts#L11)
50+
[src/Guard.ts:11](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/Guard.ts#L11)
5151

5252
## Methods
5353

@@ -67,7 +67,7 @@ An abstract class, which is the parent class of all Guards. (Names starting with
6767

6868
#### Defined in
6969

70-
[src/Guard.ts:13](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/Guard.ts#L13)
70+
[src/Guard.ts:13](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/Guard.ts#L13)
7171

7272
___
7373

@@ -87,4 +87,4 @@ value is T
8787

8888
#### Defined in
8989

90-
[src/Guard.ts:12](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/Guard.ts#L12)
90+
[src/Guard.ts:12](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/Guard.ts#L12)

docs/classes/ValidationError.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Error.constructor
4848

4949
#### Defined in
5050

51-
[src/errors.ts:5](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/errors.ts#L5)
51+
[src/errors.ts:5](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/errors.ts#L5)
5252

5353
## Properties
5454

@@ -58,7 +58,7 @@ Error.constructor
5858

5959
#### Defined in
6060

61-
[src/errors.ts:3](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/errors.ts#L3)
61+
[src/errors.ts:3](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/errors.ts#L3)
6262

6363
___
6464

@@ -96,7 +96,7 @@ ___
9696

9797
#### Defined in
9898

99-
[src/errors.ts:2](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/errors.ts#L2)
99+
[src/errors.ts:2](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/errors.ts#L2)
100100

101101
___
102102

docs/modules.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Infers the type, that the given `Guard` guards.
6868

6969
#### Defined in
7070

71-
[src/Guard.ts:22](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/Guard.ts#L22)
71+
[src/Guard.ts:22](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/Guard.ts#L22)
7272

7373
___
7474

@@ -82,7 +82,7 @@ ___
8282

8383
#### Defined in
8484

85-
[src/guards/TObject/types.ts:16](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TObject/types.ts#L16)
85+
[src/guards/TObject/types.ts:16](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TObject/types.ts#L16)
8686

8787
## Variables
8888

@@ -96,7 +96,7 @@ Guard that accepts any value.
9696

9797
#### Defined in
9898

99-
[src/guards/TAny/index.ts:8](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TAny/index.ts#L8)
99+
[src/guards/TAny/index.ts:8](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TAny/index.ts#L8)
100100

101101
___
102102

@@ -111,7 +111,7 @@ Does not accept null.
111111

112112
#### Defined in
113113

114-
[src/guards/TAnyObject/index.ts:9](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TAnyObject/index.ts#L9)
114+
[src/guards/TAnyObject/index.ts:9](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TAnyObject/index.ts#L9)
115115

116116
___
117117

@@ -125,7 +125,7 @@ Primitive guard that only accepts `bigint` values.
125125

126126
#### Defined in
127127

128-
[src/guards/TBigInt/index.ts:8](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TBigInt/index.ts#L8)
128+
[src/guards/TBigInt/index.ts:8](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TBigInt/index.ts#L8)
129129

130130
___
131131

@@ -139,7 +139,7 @@ Primitive guard that only accepts `boolean` values.
139139

140140
#### Defined in
141141

142-
[src/guards/TBoolean/index.ts:8](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TBoolean/index.ts#L8)
142+
[src/guards/TBoolean/index.ts:8](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TBoolean/index.ts#L8)
143143

144144
___
145145

@@ -153,7 +153,7 @@ Primitive guard that only accepts `function` values.
153153

154154
#### Defined in
155155

156-
[src/guards/TFunction/index.ts:8](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TFunction/index.ts#L8)
156+
[src/guards/TFunction/index.ts:8](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TFunction/index.ts#L8)
157157

158158
___
159159

@@ -174,7 +174,7 @@ TInteger.isValid(15); // true
174174

175175
#### Defined in
176176

177-
[src/guards/TInteger/index.ts:15](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TInteger/index.ts#L15)
177+
[src/guards/TInteger/index.ts:15](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TInteger/index.ts#L15)
178178

179179
___
180180

@@ -195,7 +195,7 @@ TIntegerAsString.isValid("15"); // true
195195

196196
#### Defined in
197197

198-
[src/guards/TIntegerAsString/index.ts:16](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TIntegerAsString/index.ts#L16)
198+
[src/guards/TIntegerAsString/index.ts:16](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TIntegerAsString/index.ts#L16)
199199

200200
___
201201

@@ -209,7 +209,7 @@ Guard that only accepts `null`.
209209

210210
#### Defined in
211211

212-
[src/guards/TNull/index.ts:8](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TNull/index.ts#L8)
212+
[src/guards/TNull/index.ts:8](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TNull/index.ts#L8)
213213

214214
___
215215

@@ -224,7 +224,7 @@ Not accepts `NaN`.
224224

225225
#### Defined in
226226

227-
[src/guards/TNumber/index.ts:9](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TNumber/index.ts#L9)
227+
[src/guards/TNumber/index.ts:9](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TNumber/index.ts#L9)
228228

229229
___
230230

@@ -245,7 +245,7 @@ TNumberAsString.isValid("15.223"); // true
245245

246246
#### Defined in
247247

248-
[src/guards/TNumberAsString/index.ts:15](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TNumberAsString/index.ts#L15)
248+
[src/guards/TNumberAsString/index.ts:15](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TNumberAsString/index.ts#L15)
249249

250250
___
251251

@@ -259,7 +259,7 @@ Primitive guard that only accepts `string` values.
259259

260260
#### Defined in
261261

262-
[src/guards/TString/index.ts:8](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TString/index.ts#L8)
262+
[src/guards/TString/index.ts:8](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TString/index.ts#L8)
263263

264264
___
265265

@@ -280,7 +280,7 @@ TStringEmail.name === "string(email)"; // true
280280

281281
#### Defined in
282282

283-
[src/guards/TStringEmail/index.ts:16](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringEmail/index.ts#L16)
283+
[src/guards/TStringEmail/index.ts:16](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringEmail/index.ts#L16)
284284

285285
___
286286

@@ -301,7 +301,7 @@ TStringISODate.name === "string(date)"; // true
301301

302302
#### Defined in
303303

304-
[src/guards/TStringISODate/index.ts:16](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringISODate/index.ts#L16)
304+
[src/guards/TStringISODate/index.ts:16](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringISODate/index.ts#L16)
305305

306306
___
307307

@@ -322,7 +322,7 @@ TStringJSON.name === "string(JSON)"; // true
322322

323323
#### Defined in
324324

325-
[src/guards/TStringJSON/index.ts:16](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringJSON/index.ts#L16)
325+
[src/guards/TStringJSON/index.ts:16](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringJSON/index.ts#L16)
326326

327327
___
328328

@@ -343,7 +343,7 @@ TStringJWT.name === "string(JSON)"; // true
343343

344344
#### Defined in
345345

346-
[src/guards/TStringJWT/index.ts:16](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringJWT/index.ts#L16)
346+
[src/guards/TStringJWT/index.ts:16](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringJWT/index.ts#L16)
347347

348348
___
349349

@@ -364,7 +364,7 @@ TStringMIMEType.name === "string(MIME type)"; // true
364364

365365
#### Defined in
366366

367-
[src/guards/TStringMIMEType/index.ts:16](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringMIMEType/index.ts#L16)
367+
[src/guards/TStringMIMEType/index.ts:16](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringMIMEType/index.ts#L16)
368368

369369
___
370370

@@ -386,7 +386,7 @@ TStringPhoneNumber.name === "string(phone number)"; // true
386386

387387
#### Defined in
388388

389-
[src/guards/TStringPhoneNumber/index.ts:17](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringPhoneNumber/index.ts#L17)
389+
[src/guards/TStringPhoneNumber/index.ts:17](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringPhoneNumber/index.ts#L17)
390390

391391
___
392392

@@ -407,7 +407,7 @@ TStringSemVer.name === "string(SemVer)"; // true
407407

408408
#### Defined in
409409

410-
[src/guards/TStringSemVer/index.ts:16](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringSemVer/index.ts#L16)
410+
[src/guards/TStringSemVer/index.ts:16](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringSemVer/index.ts#L16)
411411

412412
___
413413

@@ -428,7 +428,7 @@ TStringURL.name === "string(URL)"; // true
428428

429429
#### Defined in
430430

431-
[src/guards/TStringURL/index.ts:16](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringURL/index.ts#L16)
431+
[src/guards/TStringURL/index.ts:16](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringURL/index.ts#L16)
432432

433433
___
434434

@@ -452,7 +452,7 @@ TStringUUID.name === "string(UUID)"; // true
452452

453453
#### Defined in
454454

455-
[src/guards/TStringUUID/index.ts:19](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringUUID/index.ts#L19)
455+
[src/guards/TStringUUID/index.ts:19](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringUUID/index.ts#L19)
456456

457457
___
458458

@@ -466,7 +466,7 @@ Primitive guard that only accepts `undefined` values.
466466

467467
#### Defined in
468468

469-
[src/guards/TUndefined/index.ts:8](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TUndefined/index.ts#L8)
469+
[src/guards/TUndefined/index.ts:8](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TUndefined/index.ts#L8)
470470

471471
## Functions
472472

@@ -503,7 +503,7 @@ Accepts a value when it was accepted by all `guardA` and `guardB`, and others.
503503

504504
#### Defined in
505505

506-
[src/guards/TAnd/index.ts:14](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TAnd/index.ts#L14)
506+
[src/guards/TAnd/index.ts:14](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TAnd/index.ts#L14)
507507

508508
___
509509

@@ -546,7 +546,7 @@ A `Guard` that checks if the given value is an array of the given type.
546546

547547
#### Defined in
548548

549-
[src/guards/TArray/index.ts:24](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TArray/index.ts#L24)
549+
[src/guards/TArray/index.ts:24](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TArray/index.ts#L24)
550550

551551
___
552552

@@ -589,7 +589,7 @@ A `Guard` which checks if the given value is equals to the `constant` literal.
589589

590590
#### Defined in
591591

592-
[src/guards/TConstant/index.ts:26](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TConstant/index.ts#L26)
592+
[src/guards/TConstant/index.ts:26](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TConstant/index.ts#L26)
593593

594594
___
595595

@@ -628,7 +628,7 @@ A `Guard` that accepts a value when it was **not** accepted by the given guard.
628628

629629
#### Defined in
630630

631-
[src/guards/TNot/index.ts:21](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TNot/index.ts#L21)
631+
[src/guards/TNot/index.ts:21](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TNot/index.ts#L21)
632632

633633
___
634634

@@ -676,13 +676,13 @@ A `Guard`.
676676

677677
#### Defined in
678678

679-
[src/guards/TObject/index.ts:31](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TObject/index.ts#L31)
679+
[src/guards/TObject/index.ts:31](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TObject/index.ts#L31)
680680

681681
___
682682

683683
### TObjectOfShape
684684

685-
**TObjectOfShape**<`T`\>(`shape`): [`Guard`](classes/Guard.md)<`Record`<`string`, `T`\>\>
685+
**TObjectOfShape**<`T`\>(`shape`): [`Guard`](classes/Guard.md)<{ `[key: string]`: `T`; }\>
686686

687687
Validates the shape of an object.
688688

@@ -722,7 +722,7 @@ guard.name === "{ [string]: number }"; // true
722722

723723
#### Returns
724724

725-
[`Guard`](classes/Guard.md)<`Record`<`string`, `T`\>\>
725+
[`Guard`](classes/Guard.md)<{ `[key: string]`: `T`; }\>
726726

727727
A `Guard` that checks if the given value matches the provided object shape.
728728

@@ -734,7 +734,7 @@ Similar in concept as TypeScript's `{[keys: string]: number}` type annotations.
734734

735735
#### Defined in
736736

737-
[src/guards/TObjectOfShape/index.ts:39](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TObjectOfShape/index.ts#L39)
737+
[src/guards/TObjectOfShape/index.ts:39](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TObjectOfShape/index.ts#L39)
738738

739739
___
740740

@@ -780,7 +780,7 @@ Accepts a value when it was accepted by at least one of the `guards`.
780780

781781
#### Defined in
782782

783-
[src/guards/TOr/index.ts:22](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TOr/index.ts#L22)
783+
[src/guards/TOr/index.ts:22](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TOr/index.ts#L22)
784784

785785
___
786786

@@ -814,7 +814,7 @@ A `Guard` that accepts only strings that are base64 encoded.
814814

815815
#### Defined in
816816

817-
[src/guards/TStringBase64/index.ts:21](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringBase64/index.ts#L21)
817+
[src/guards/TStringBase64/index.ts:21](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringBase64/index.ts#L21)
818818

819819
___
820820

@@ -849,7 +849,7 @@ A `Guard` that accepts only strings that matches the given `regexp`.
849849

850850
#### Defined in
851851

852-
[src/guards/TStringMatch/index.ts:23](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringMatch/index.ts#L23)
852+
[src/guards/TStringMatch/index.ts:23](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringMatch/index.ts#L23)
853853

854854
___
855855

@@ -884,7 +884,7 @@ A `Guard` that accepts only strings, that is in the given length range.
884884

885885
#### Defined in
886886

887-
[src/guards/TStringWithLength/index.ts:22](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TStringWithLength/index.ts#L22)
887+
[src/guards/TStringWithLength/index.ts:22](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TStringWithLength/index.ts#L22)
888888

889889
___
890890

@@ -922,4 +922,4 @@ const TBiggerThan10 = TValidate<number>(
922922

923923
#### Defined in
924924

925-
[src/guards/TValidate/index.ts:22](https://github.com/davidkarolyi/tguard/blob/f2e7a9f/src/guards/TValidate/index.ts#L22)
925+
[src/guards/TValidate/index.ts:22](https://github.com/davidkarolyi/tguard/blob/458c9b2/src/guards/TValidate/index.ts#L22)

src/guards/TObjectOfShape/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ import TValidate from "../TValidate";
3939
export default function TObjectOfShape<T>(shape: {
4040
keys: Guard<string>;
4141
values: Guard<T>;
42-
}): Guard<Record<string, T>> {
42+
}): Guard<{ [key: string]: T }> {
4343
const name = `{ [${shape.keys.name}]: ${shape.values.name} }`;
4444

45-
return TValidate<Record<string, T>>(name, (value) => {
45+
return TValidate<{ [key: string]: T }>(name, (value) => {
4646
{
4747
if (typeof value !== "object" || value === null) return false;
4848
for (const key in value) {

0 commit comments

Comments
 (0)