Skip to content

Commit 353841f

Browse files
authored
chore: update stnl code to 1.1.6
1 parent e73ecb4 commit 353841f

File tree

1 file changed

+14
-28
lines changed

1 file changed

+14
-28
lines changed

cases/stnl.ts

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,24 @@
11
import compose from 'stnl/compilers/validate-json/compose';
2-
import { build } from 'stnl/compilers/validate-json';
3-
import stnl from 'stnl';
2+
import { build, t } from 'stnl';
43

54
import { createCase } from '../benchmarks';
65

7-
const assertLoose = stnl({
8-
props: {
9-
number: 'f64',
10-
negNumber: 'f64',
11-
maxNumber: 'f64',
12-
string: 'string',
13-
longString: 'string',
14-
boolean: 'bool',
15-
deeplyNested: {
16-
props: {
17-
foo: 'string',
18-
num: 'f64',
19-
bool: 'bool',
20-
},
21-
},
22-
},
23-
});
24-
25-
createCase('stnl (composition)', 'assertLoose', () => {
26-
const check = compose(assertLoose);
27-
28-
return data => {
29-
if (check(data)) return true;
30-
throw null;
31-
};
6+
const assertLoose = t.dict({
7+
number: t.float,
8+
negNumber: t.float,
9+
maxNumber: t.float,
10+
string: t.string,
11+
longString: t.string,
12+
boolean: t.bool,
13+
deeplyNested: t.dict({
14+
foo: t.string,
15+
num: t.float,
16+
bool: t.bool
17+
})
3218
});
3319

3420
createCase('stnl (just-in-time)', 'assertLoose', () => {
35-
const check = build(assertLoose);
21+
const check = build.json.assert.compile(assertLoose);
3622

3723
return data => {
3824
if (check(data)) return true;

0 commit comments

Comments
 (0)