UNPKG

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