cuelang.org/go@v0.13.0/cue/testdata/resolve/013_custom_validators.txtar (about)

     1  #name: custom validators
     2  #evalPartial
     3  -- in.cue --
     4  import "strings"
     5  
     6  a: strings.ContainsAny("ab")
     7  a: "after"
     8  
     9  b: strings.ContainsAny("c")
    10  b: "dog"
    11  
    12  c: strings.ContainsAny("d") & strings.ContainsAny("g")
    13  c: "dog"
    14  -- out/def --
    15  a: "after"
    16  b: _|_ // invalid value "dog" (does not satisfy strings.ContainsAny("c"))
    17  c: "dog"
    18  -- out/legacy-debug --
    19  <0>{a: "after", b: _|_(strings.ContainsAny ("c"):invalid value "dog" (does not satisfy strings.ContainsAny("c"))), c: "dog"}
    20  -- out/eval/stats --
    21  Leaks:  0
    22  Freed:  4
    23  Reused: 2
    24  Allocs: 2
    25  Retain: 0
    26  
    27  Unifications: 4
    28  Conjuncts:    8
    29  Disjuncts:    4
    30  -- out/eval --
    31  Errors:
    32  b: invalid value "dog" (does not satisfy strings.ContainsAny("c")):
    33      ./in.cue:6:4
    34      ./in.cue:6:24
    35      ./in.cue:7:4
    36  
    37  Result:
    38  (_|_){
    39    // [eval]
    40    a: (string){ "after" }
    41    b: (_|_){
    42      // [eval] b: invalid value "dog" (does not satisfy strings.ContainsAny("c")):
    43      //     ./in.cue:6:4
    44      //     ./in.cue:6:24
    45      //     ./in.cue:7:4
    46    }
    47    c: (string){ "dog" }
    48  }
    49  -- out/compile --
    50  --- in.cue
    51  {
    52    a: 〈import;strings〉.ContainsAny("ab")
    53    a: "after"
    54    b: 〈import;strings〉.ContainsAny("c")
    55    b: "dog"
    56    c: (〈import;strings〉.ContainsAny("d") & 〈import;strings〉.ContainsAny("g"))
    57    c: "dog"
    58  }