File: 013_custom_validators.txtar

package info (click to toggle)
golang-github-cue-lang-cue 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,644 kB
  • sloc: makefile: 20; sh: 15
file content (58 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#name: custom validators
#evalPartial
-- in.cue --
import "strings"

a: strings.ContainsAny("ab")
a: "after"

b: strings.ContainsAny("c")
b: "dog"

c: strings.ContainsAny("d") & strings.ContainsAny("g")
c: "dog"
-- out/def --
a: "after"
b: _|_ // invalid value "dog" (does not satisfy strings.ContainsAny("c"))
c: "dog"
-- out/legacy-debug --
<0>{a: "after", b: _|_(strings.ContainsAny ("c"):invalid value "dog" (does not satisfy strings.ContainsAny("c"))), c: "dog"}
-- out/eval/stats --
Leaks:  0
Freed:  4
Reused: 2
Allocs: 2
Retain: 0

Unifications: 4
Conjuncts:    8
Disjuncts:    4
-- out/eval --
Errors:
b: invalid value "dog" (does not satisfy strings.ContainsAny("c")):
    ./in.cue:6:4
    ./in.cue:6:24
    ./in.cue:7:4

Result:
(_|_){
  // [eval]
  a: (string){ "after" }
  b: (_|_){
    // [eval] b: invalid value "dog" (does not satisfy strings.ContainsAny("c")):
    //     ./in.cue:6:4
    //     ./in.cue:6:24
    //     ./in.cue:7:4
  }
  c: (string){ "dog" }
}
-- out/compile --
--- in.cue
{
  a: 〈import;strings〉.ContainsAny("ab")
  a: "after"
  b: 〈import;strings〉.ContainsAny("c")
  b: "dog"
  c: (〈import;strings〉.ContainsAny("d") & 〈import;strings〉.ContainsAny("g"))
  c: "dog"
}