1 | import { log, time } from '../common';
|
2 | import { Schema } from '..';
|
3 |
|
4 | const timer = time.timer();
|
5 |
|
6 | const schema = Schema.compile({
|
7 | files: 'types/index.ts',
|
8 | basePath: './src/example',
|
9 | required: true,
|
10 | strictNullChecks: true,
|
11 | });
|
12 |
|
13 | log.info('elapsed', timer.elapsed());
|
14 | log.info('-------------------------------------------\n');
|
15 | timer.reset();
|
16 |
|
17 | const foo = schema.forType('IFoo');
|
18 | log.info('foo:', foo);
|
19 | log.info('elapsed', timer.elapsed());
|
20 | log.info('-------------------------------------------\n');
|
21 |
|
22 | const isValid = foo.validate({ name: 'Bob', age: 31 });
|
23 | const isNotValid = foo.validate({ name: true });
|
24 |
|
25 | log.info('isValid:', isValid);
|
26 | log.info('isNotValid:', isNotValid);
|
27 | log.info('elapsed', timer.elapsed());
|
28 | log.info('-------------------------------------------\n');
|