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
|
diff --git a/README.md b/README.md
index cb62ba1b4d23cb413384de0a7b56160621990173..83527108b379da08fceed5d4e12cdf95cec65e6b 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ CUE + Jsonnet
## Usage
-[Example Schema](testdata/schema.cue)
+[Example Schema](testdata/person/schema.cue)
```cue
import "time"
@@ -31,7 +31,7 @@ // Apply the schema to root
#Schema
```
-[Example Jsonnet](testdata/fixed.jsonnet)
+[Example Jsonnet](testdata/person/valid.jsonnet)
```jsonnet
{
@@ -41,6 +41,23 @@ age: 45,
birthday: '01/02/2003',
}
```
+
+Embedding the schema is the recommended pattern:
+
+```go
+//go:embed schema.cue
+var schema cuesonnet.Schema
+
+var result MyStruct
+if err := schema.Decode(r, &result); err != nil {
+ // handle validation errors
+}
+```
+
+## Tests
+
+`testdata/` contains a large list of schemas and Jsonnet fixtures covering CUE features (types, constraints, structs, lists, disjunctions, defaults, definitions, composition, stdlib) and Jsonnet features (functions, comprehensions, conditionals, inheritance, multiline strings, self-reference, stdlib).
+See `cuesonnet_test.go` and `cuesonnet_decode_test.go`.
## License
|