cue-lang / docs-and-content

A place to discuss, plan, and track documentation on cuelang.org
5 stars 1 forks source link

docs/howto: Validating YAML using the Go API #150

Open jpluscplusm opened 1 month ago

jpluscplusm commented 1 month ago

In https://cuelang.org/cl/1194700 we added "How to validate JSON using the Go API".

I tried to create a YAML counterpart by copying the JSON guide, and simply swapping JSON (and its other cases) for YAML throughout the page.

I discovered that encoding/json.Extract() and encoding/yaml.Extract() aren't symmetric, being told that

./main.go:36:29: cannot use dataExpr (variable of type ast.File) as ast.Expr value in argument to ctx.BuildExpr: ast.File does not implement ast.Expr (missing method declNode)

This issue tracks the creation of that YAML counterpart.

jpluscplusm commented 1 month ago

Perhaps the tested code example present at https://cuelang.org/docs/concept/how-cue-works-with-go/#loading-non-cue-data can help a non-expert write this guide.