File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,20 @@ const defaultMethods = {
203203 }
204204 }
205205 } ,
206+ // Adding this to spec something out, not to merge it.
207+ val : {
208+ method : ( args , context ) => {
209+ let result = context
210+ for ( let i = 0 ; i < args . length ; i ++ ) {
211+ if ( args [ i ] === null ) continue
212+ if ( result === null || result === undefined ) return null
213+ result = result [ args [ i ] ]
214+ }
215+ if ( typeof result === 'undefined' ) return null
216+ return result
217+ } ,
218+ deterministic : false
219+ } ,
206220 var : ( key , context , above , engine ) => {
207221 let b
208222 if ( Array . isArray ( key ) ) {
Original file line number Diff line number Diff line change 1+ [
2+ " Test Specification for val" ,
3+ {
4+ "description" : " Fetches a value from an empty key" ,
5+ "rule" : { "val" : " " },
6+ "data" : { "" : 1 },
7+ "result" : 1
8+ },
9+ {
10+ "description" : " Fetches a value from a nested empty key" ,
11+ "rule" : { "val" : [" " , " " ] },
12+ "data" : { "" : { "" : 2 } },
13+ "result" : 2
14+ },
15+ {
16+ "description" : " Fetches a value from a doubly nested empty key" ,
17+ "rule" : { "val" : [" " , " " , " " ] },
18+ "data" : { "" : { "" : { "" : 3 } } },
19+ "result" : 3
20+ },
21+ {
22+ "description" : " Fetches a value from a key that is purely a dot" ,
23+ "rule" : { "val" : " ." },
24+ "data" : { "." : 20 },
25+ "result" : 20
26+ },
27+ {
28+ "description" : " Fetches the entire context" ,
29+ "rule" : { "val" : null },
30+ "data" : { "" : 21 },
31+ "result" : { "" : 21 }
32+ },
33+ {
34+ "description" : " Fetches the entire context for a nested key" ,
35+ "rule" : { "val" : " " },
36+ "data" : { "" : { "" : 22 } },
37+ "result" : { "" : 22 }
38+ }
39+ ]
You can’t perform that action at this time.
0 commit comments