Home

cuesonnet @main - refs - log -
-
https://git.jolheiser.com/cuesonnet.git
CUE + Jsonnet
tree log patch
update README Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQAoVKPZxClgDa8BOi06l2Rs74fZ0DOqu2i15pkxOaHPoVUS5LDNehm6EnHL2YeFM3d sMiw9hMckOgQrv/mj/3Ak= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
4 hours ago
1 changed files, 19 additions(+), 2 deletions(-)
README.md
M README.md -> README.md
 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