File tree Expand file tree Collapse file tree 1 file changed +14
-28
lines changed Expand file tree Collapse file tree 1 file changed +14
-28
lines changed Original file line number Diff line number Diff line change 11import 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
54import { 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
3420createCase ( '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 ;
You can’t perform that action at this time.
0 commit comments