Skip to content

Commit d58a66c

Browse files
committed
Fix type cast for uuid rule
Signed-off-by: Andrei Kazakou <a.v.kazakou@gmail.com>
1 parent b6b3225 commit d58a66c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/typescript/rules/uuid.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference path="../../../index.d.ts" /> // here we make a reference to exists module definition
2-
import ValidatorType from 'fastest-validator'; // here we importing type definition of default export
2+
import ValidatorType, { RuleUUID } from 'fastest-validator'; // here we importing type definition of default export
33

44
const Validator: typeof ValidatorType = require('../../../index'); // here we importing real Validator Constructor
55
const v: ValidatorType = new Validator();
@@ -32,11 +32,11 @@ describe('TypeScript Definitions', () => {
3232
expect(check('00000000-0000-7000-0000-000000000000')).toEqual([{ type: 'uuid', actual: '00000000-0000-7000-0000-000000000000', message }]);
3333
expect(check('fdda765f-fc57-5604-c269-52a7df8164ec')).toEqual([{ type: 'uuid', actual: 'fdda765f-fc57-5604-c269-52a7df8164ec', message }]);
3434

35-
const check1 = v.compile({ $$root: true, type: 'uuid', version: 1 });
36-
const check2 = v.compile({ $$root: true, type: 'uuid', version: 2 });
37-
const check3 = v.compile({ $$root: true, type: 'uuid', version: 3 });
38-
const check4 = v.compile({ $$root: true, type: 'uuid', version: 4 });
39-
const check5 = v.compile({ $$root: true, type: 'uuid', version: 5 });
35+
const check1 = v.compile({ $$root: true, type: 'uuid', version: 1 } as RuleUUID);
36+
const check2 = v.compile({ $$root: true, type: 'uuid', version: 2 } as RuleUUID);
37+
const check3 = v.compile({ $$root: true, type: 'uuid', version: 3 } as RuleUUID);
38+
const check4 = v.compile({ $$root: true, type: 'uuid', version: 4 } as RuleUUID);
39+
const check5 = v.compile({ $$root: true, type: 'uuid', version: 5 } as RuleUUID);
4040
message = 'The \'\' field must be a valid UUID version provided.';
4141

4242
expect(check1('9a7b330a-a736-51e5-af7f-feaf819cdc9f')).toEqual([{ 'actual': 5, 'expected': 1, 'type': 'uuidVersion', message }]);
@@ -48,11 +48,11 @@ describe('TypeScript Definitions', () => {
4848
});
4949

5050
it('check valid version', () => {
51-
const check1 = v.compile({ $$root: true, type: 'uuid', version: 1 });
52-
const check2 = v.compile({ $$root: true, type: 'uuid', version: 2 });
53-
const check3 = v.compile({ $$root: true, type: 'uuid', version: 3 });
54-
const check4 = v.compile({ $$root: true, type: 'uuid', version: 4 });
55-
const check5 = v.compile({ $$root: true, type: 'uuid', version: 5 });
51+
const check1 = v.compile({ $$root: true, type: 'uuid', version: 1 } as RuleUUID);
52+
const check2 = v.compile({ $$root: true, type: 'uuid', version: 2 } as RuleUUID);
53+
const check3 = v.compile({ $$root: true, type: 'uuid', version: 3 } as RuleUUID);
54+
const check4 = v.compile({ $$root: true, type: 'uuid', version: 4 } as RuleUUID);
55+
const check5 = v.compile({ $$root: true, type: 'uuid', version: 5 } as RuleUUID);
5656

5757
expect(check1('45745c60-7b1a-11e8-9c9c-2d42b21b1a3e')).toEqual(true);
5858
expect(check2('9a7b330a-a736-21e5-af7f-feaf819cdc9f')).toEqual(true);

0 commit comments

Comments
 (0)