Repository: kcl-lang/kcl-go
Pull request #168 (2023-10-24 11:57:04)

chore(deps): bump github.com/docker/distribution from 2.8.1+incompatible to 2.8.2+incompatible
Bumps [github.com/docker/distribution](https://github.com/docker/distribution) from 2.8.1+incompatible to 2.8.2+incompatible.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/docker/distribution/releases">github.com/docker/distribution's releases</a>.</em></p>
<blockquote>
<h2>v2.8.2</h2>
<h2>What's Changed</h2>
<ul>
<li>Revert registry/client: set <code>Accept: identity</code> header when getting layers by <a href="https://github.com/ndeloof"><code>@​ndeloof</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3783">distribution/distribution#3783</a></li>
<li>Parse <code>http</code> forbidden as denied by <a href="https://github.com/vvoland"><code>@​vvoland</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3914">distribution/distribution#3914</a></li>
<li>Fix <a href="https://www.cve.org/CVERecord?id=CVE-2022-28391">CVE-2022-28391</a> by bumping alpine from 3.14 to 3.16 by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> (<a href="https://redirect.github.com/distribution/distribution/pull/3650">#3650</a>)</li>
<li>Fix <a href="https://www.cve.org/CVERecord?id=CVE-2023-2253">CVE-2023-2253</a> runaway allocation on /v2/_catalog  by <a href="https://github.com/josegomezr"><code>@​josegomezr</code></a> <a href="https://github.com/distribution/distribution/commit/521ea3d973cb0c7089ebbcdd4ccadc34be941f54"><code>521ea3d9</code></a></li>
<li>Fix panic in inmemory driver by <a href="https://github.com/wy65701436"><code>@​wy65701436</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3815">distribution/distribution#3815</a></li>
<li>bump up golang version (alternative) by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3903">distribution/distribution#3903</a></li>
<li>Dockerfile: update xx to v1.2.1 by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3907">distribution/distribution#3907</a></li>
<li>update to go1.19.9 by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3908">distribution/distribution#3908</a></li>
<li>Add code to handle pagination of parts. Fixes max layer size of 10GB bug by <a href="https://github.com/DavidSpek"><code>@​DavidSpek</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3893">distribution/distribution#3893</a></li>
<li>Dockerfile: fix filenames of artifacts by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3911">distribution/distribution#3911</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/distribution/distribution/compare/v2.8.1...v2.8.2">https://github.com/distribution/distribution/compare/v2.8.1...v2.8.2</a></p>
<h2>v2.8.2-beta.2</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix <a href="https://www.cve.org/CVERecord?id=CVE-2022-28391">CVE-2022-28391</a> by bumping alpine from 3.14 to 3.16 by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> (<a href="https://redirect.github.com/distribution/distribution/pull/3650">#3650</a>)</li>
<li>Fix <a href="https://www.cve.org/CVERecord?id=CVE-2023-2253">CVE-2023-2253</a> runaway allocation on /v2/_catalog  by <a href="https://github.com/josegomezr"><code>@​josegomezr</code></a> <a href="https://github.com/distribution/distribution/commit/521ea3d973cb0c7089ebbcdd4ccadc34be941f54"><code>521ea3d9</code></a></li>
<li>Fix panic in inmemory driver by <a href="https://github.com/wy65701436"><code>@​wy65701436</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3815">distribution/distribution#3815</a></li>
<li>bump up golang version (alternative) by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3903">distribution/distribution#3903</a></li>
<li>Dockerfile: update xx to v1.2.1 by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3907">distribution/distribution#3907</a></li>
<li>update to go1.19.9 by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3908">distribution/distribution#3908</a></li>
<li>Add code to handle pagination of parts. Fixes max layer size of 10GB bug by <a href="https://github.com/DavidSpek"><code>@​DavidSpek</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3893">distribution/distribution#3893</a></li>
<li>Dockerfile: fix filenames of artifacts by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3911">distribution/distribution#3911</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/distribution/distribution/compare/v2.8.1...v2.8.2-beta.2">https://github.com/distribution/distribution/compare/v2.8.1...v2.8.2-beta.2</a></p>
<h2>v2.8.2-beta.1</h2>
<h3><strong>NOTE: This is a pre-release that does not contain any artifacts!</strong></h3>
<h2>What's Changed</h2>
<ul>
<li>Fix runaway allocation on /v2/_catalog by <a href="https://github.com/josegomezr"><code>@​josegomezr</code></a> <a href="https://github.com/distribution/distribution/commit/521ea3d973cb0c7089ebbcdd4ccadc34be941f54"><code>521ea3d9</code></a></li>
<li>Fix CVE-2022-28391 by bumping alpine from 3.14 to 3.16 by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3650">distribution/distribution#3650</a></li>
<li>Fix panic in inmemory driver by <a href="https://github.com/wy65701436"><code>@​wy65701436</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3815">distribution/distribution#3815</a></li>
<li>bump up golang version (alternative) by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3903">distribution/distribution#3903</a></li>
<li>Dockerfile: update xx to v1.2.1 by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3907">distribution/distribution#3907</a></li>
<li>update to go1.19.9 by <a href="https://github.com/thaJeztah"><code>@​thaJeztah</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3908">distribution/distribution#3908</a></li>
<li>Add code to handle pagination of parts. Fixes max layer size of 10GB bug by <a href="https://github.com/DavidSpek"><code>@​DavidSpek</code></a> in <a href="https://redirect.github.com/distribution/distribution/pull/3893">distribution/distribution#3893</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/distribution/distribution/compare/v2.8.1...v2.8.2-beta.1">https://github.com/distribution/distribution/compare/v2.8.1...v2.8.2-beta.1</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/distribution/distribution/commit/7c354a4b40feeea21d7eeae4de91c8ff7951e672"><code>7c354a4</code></a> Merge pull request <a href="https://redirect.github.com/docker/distribution/issues/3915">#3915</a> from distribution/2.8.2-release-notes</li>
<li><a href="https://github.com/distribution/distribution/commit/a173a9c625cdc84498580e4f486b36d4c9859065"><code>a173a9c</code></a> Add v2.8.2 release notes</li>
<li><a href="https://github.com/distribution/distribution/commit/4894d35ecc831b114d86cd3795573e5f4f306ea7"><code>4894d35</code></a> Merge pull request <a href="https://redirect.github.com/docker/distribution/issues/3914">#3914</a> from vvoland/handle-forbidden-28</li>
<li><a href="https://github.com/distribution/distribution/commit/f067f66d3de1fd82d6bf139d15130ff59d3db7e1"><code>f067f66</code></a> Merge pull request <a href="https://redirect.github.com/docker/distribution/issues/3783">#3783</a> from ndeloof/accept-encoding-28</li>
<li><a href="https://github.com/distribution/distribution/commit/483ad69da3e3fb9ac885962d50834ff8619733a2"><code>483ad69</code></a> registry/errors: Parse http forbidden as denied</li>
<li><a href="https://github.com/distribution/distribution/commit/2b0f84df21e062bd0cc3676557c6bee4cbb9e9bc"><code>2b0f84d</code></a> Revert &quot;registry/client: set Accept: identity header when getting layers&quot;</li>
<li><a href="https://github.com/distribution/distribution/commit/320d6a141f17d11c44f98fd975b2368705e27971"><code>320d6a1</code></a> Merge pull request <a href="https://redirect.github.com/docker/distribution/issues/3912">#3912</a> from distribution/2.8.2-beta.2-release-notes</li>
<li><a href="https://github.com/distribution/distribution/commit/5f3ca1b2fb6109705d729816e7260a6966d2b42d"><code>5f3ca1b</code></a> Add release notes for 2.8.2-beta.2 release</li>
<li><a href="https://github.com/distribution/distribution/commit/cb840f63b3b27cce503aee5e3291750f3cd90c1c"><code>cb840f6</code></a> Merge pull request <a href="https://redirect.github.com/docker/distribution/issues/3911">#3911</a> from thaJeztah/2.8_backport_fix_releaser_filenames</li>
<li><a href="https://github.com/distribution/distribution/commit/e884644fff38a5bf601a2272f434ee2b01dd2b17"><code>e884644</code></a> Dockerfile: fix filenames of artifacts</li>
<li>Additional commits viewable in <a href="https://github.com/docker/distribution/compare/v2.8.1...v2.8.2">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/docker/distribution&package-manager=go_modules&previous-version=2.8.1+incompatible&new-version=2.8.2+incompatible)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/kcl-lang/kcl-go/network/alerts).

</details>


Patch:
diff --git a/examples/hello/hello.k b/examples/hello/hello.k
deleted file mode 100644
index 2f5e052..0000000
--- a/examples/hello/hello.k
+++ /dev/null
@@ -1,1 +0,0 @@
-# keep file path valid
\ No newline at end of file
diff --git a/examples/hello/main.go b/examples/hello/main.go
deleted file mode 100644
index 1620162..0000000
--- a/examples/hello/main.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2023 The KCL Authors. All rights reserved.
-
-// Run CGO Mode:
-// KCLVM_SERVICE_CLIENT_HANDLER=native KCLVM_PLUGIN_DEBUG=1 go run -tags=kclvm_service_capi .
-
-package main
-
-import (
-	"fmt"
-
-	"kcl-lang.io/kcl-go"
-	_ "kcl-lang.io/kcl-go/pkg/kcl_plugin/hello_plugin"
-)
-
-func main() {
-	yaml := kclvm.MustRun("hello.k", kclvm.WithCode(k_code)).GetRawYamlResult()
-	fmt.Println(yaml)
-}
-
-const k_code = `
-import kcl_plugin.hello
-
-name = "kcl"
-age = 1
-two = hello.add(1, 1)
-
-hello.say_hello('hello KCL')
-
-low_kcl = hello.tolower('KCL')
-
-s = hello.update_dict({'name': 123}, 'name', 'kcl')['name']
-
-# todo: l = hello.list_append(['abc'], 'name', 123)
-
-schema Person:
-    name: str = "kcl"
-    age: int = 1
-
-x0 = Person {}
-x1 = Person {
-    age = 101
-}
-`
diff --git a/go.mod b/go.mod
index d3ca995..02ae983 100644
--- a/go.mod
+++ b/go.mod
@@ -41,7 +41,7 @@ require (
 	github.com/cyphar/filepath-securejoin v0.2.3 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
 	github.com/docker/cli v23.0.1+incompatible // indirect
-	github.com/docker/distribution v2.8.1+incompatible // indirect
+	github.com/docker/distribution v2.8.2+incompatible // indirect
 	github.com/docker/docker v23.0.1+incompatible // indirect
 	github.com/docker/docker-credential-helpers v0.7.0 // indirect
 	github.com/docker/go-connections v0.4.0 // indirect
diff --git a/go.sum b/go.sum
index d88e738..3dd372e 100644
--- a/go.sum
+++ b/go.sum
@@ -102,8 +102,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
 github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aBfCb7iqHmDEIp6fBvC/hQUddQfg+3qdYjwzaiP9Hnc=
 github.com/docker/cli v23.0.1+incompatible h1:LRyWITpGzl2C9e9uGxzisptnxAn1zfZKXy13Ul2Q5oM=
 github.com/docker/cli v23.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
-github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
-github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
+github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
+github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
 github.com/docker/docker v23.0.1+incompatible h1:vjgvJZxprTTE1A37nm+CLNAdwu6xZekyoiVlUZEINcY=
 github.com/docker/docker v23.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A=
diff --git a/pkg/kcl/opt.go b/pkg/kcl/opt.go
index e6a296d..c35b4ce 100644
--- a/pkg/kcl/opt.go
+++ b/pkg/kcl/opt.go
@@ -129,6 +129,9 @@ func WithOverrides(override_list ...string) Option {
 	var overrides []*gpyrpc.CmdOverrideSpec
 	for _, kv := range override_list {
 		idx0 := strings.Index(kv, ":")
+		if idx0 < 0 {
+			idx0 = 0
+		}
 		idx1 := strings.Index(kv, "=")
 		if idx0 >= 0 && idx1 >= 0 && idx0 < idx1 {
 			var pkgpath = kv[:idx0]
diff --git a/pkg/settings/utils_settings_yaml.go b/pkg/settings/utils_settings_yaml.go
index ed544d9..1846b01 100644
--- a/pkg/settings/utils_settings_yaml.go
+++ b/pkg/settings/utils_settings_yaml.go
@@ -23,7 +23,8 @@ type SettingsFile struct {
 }
 
 type ConfigStruct struct {
-	InputFiles []string `yaml:"file"`
+	InputFile  []string `yaml:"file"`
+	InputFiles []string `yaml:"files"`
 	Output     string   `yaml:"output"`
 
 	Overrides    []string `yaml:"overrides"`
@@ -75,9 +76,7 @@ func LoadFile(filename string, src interface{}) (f *SettingsFile, err error) {
 
 	var settings SettingsFile
 	if err := yaml.Unmarshal([]byte(code), &settings); err != nil {
-		if err2 := decodeTestFormatSettingsFile(code, &settings); err2 != nil {
-			return nil, err
-		}
+		return nil, err
 	}
 
 	settings.Filename = filename
@@ -109,7 +108,12 @@ func (settings *SettingsFile) To_ExecProgram_Args() *gpyrpc.ExecProgram_Args {
 	pkgroot, _, _ := tools_list.FindPkgInfo(args.WorkDir)
 
 	// Input files may be a KCL file folder or a single KCL file.
-	for _, s := range settings.Config.InputFiles {
+
+	var files []string
+	files = append(files, settings.Config.InputFile...)
+	files = append(files, settings.Config.InputFiles...)
+
+	for _, s := range files {
 		if strings.Contains(s, "${PWD}") {
 			s = strings.ReplaceAll(s, "${PWD}", args.WorkDir)
 		}
@@ -187,107 +191,3 @@ func (settings *SettingsFile) To_ExecProgram_Args() *gpyrpc.ExecProgram_Args {
 
 	return args
 }
-
-// kcl_options: -Y config1.yaml config2.yaml
-// kcl_options: -D key0=value0 -D key1=value1 -Y temp.yaml
-// kcl_options: -O :alice.labels.skin=white
-// kcl_options: -S :JohnDoe.* -S :list_data.* -S :dict_data.*
-// kcl_options: -d
-// kcl_options: -r
-// kcl_options: -n
-// kcl_options: pkg.k
-func decodeTestFormatSettingsFile(src string, settings *SettingsFile) error {
-	// kcl_options: -Y config1.yaml config2.yaml
-	var test_settings_yaml struct {
-		CmdArgs string `yaml:"kcl_options"`
-	}
-	err := yaml.Unmarshal([]byte(src), &test_settings_yaml)
-	if err != nil {
-		return fmt.Errorf("invalid settings file: %v, %v", err, src)
-	}
-
-	cmdArgs := strings.Fields(test_settings_yaml.CmdArgs)
-	*settings = SettingsFile{}
-
-	for len(cmdArgs) > 0 {
-		switch cmdArgs[0] {
-		case "-Y":
-			cmdArgs = cmdArgs[1:]
-			for len(cmdArgs) > 0 {
-				if strings.HasSuffix(cmdArgs[0], ".yaml") || strings.HasSuffix(cmdArgs[0], ".yml") {
-					settings.Config.InputFiles = append(settings.Config.InputFiles, cmdArgs[0])
-					cmdArgs = cmdArgs[1:]
-					continue
-				}
-				break
-			}
-		case "-D":
-			cmdArgs = cmdArgs[1:]
-			if len(cmdArgs) == 0 {
-				return fmt.Errorf("invalid kcl_options: %v %v", "-D", cmdArgs)
-			}
-
-			_D_arg := cmdArgs[0]
-			cmdArgs = cmdArgs[1:]
-
-			kv := strings.Split(_D_arg, "=")
-			if len(kv) == 0 {
-				return fmt.Errorf("invalid kcl_options: %v %v", "-D", cmdArgs)
-			}
-			if len(kv) < 2 {
-				kv = append(kv, "")
-			}
-
-			settings.Options = append(settings.Options, KeyValueStruct{
-				Key:   kv[0],
-				Value: kv[1],
-			})
-
-		case "-O":
-			// "--overrides",
-			cmdArgs = cmdArgs[1:]
-			if len(cmdArgs) == 0 {
-				return fmt.Errorf("invalid kcl_options: %v %v", "-O", cmdArgs)
-			}
-
-			_O_arg := cmdArgs[0]
-			cmdArgs = cmdArgs[1:]
-
-			settings.Config.Overrides = append(settings.Config.Overrides, _O_arg)
-
-		case "-S":
-			// "--path-selector",
-			cmdArgs = cmdArgs[1:]
-			if len(cmdArgs) == 0 {
-				return fmt.Errorf("invalid kcl_options: %v %v", "-S", cmdArgs)
-			}
-
-			_S_arg := cmdArgs[0]
-			cmdArgs = cmdArgs[1:]
-
-			settings.Config.PathSelector = append(settings.Config.PathSelector, _S_arg)
-
-		case "-n":
-			// --disable-none
-			cmdArgs = cmdArgs[1:]
-			settings.Config.DisableNone = true
-		case "-r":
-			// --strict-range-check
-			cmdArgs = cmdArgs[1:]
-			settings.Config.StrictRangeCheck = true
-		case "-d":
-			// --debug
-			cmdArgs = cmdArgs[1:]
-			settings.Config.Debug = true
-		default:
-			if strings.HasSuffix(cmdArgs[0], ".k") {
-				settings.Config.InputFiles = append(settings.Config.InputFiles, cmdArgs[0])
-				cmdArgs = cmdArgs[1:]
-			} else {
-				return fmt.Errorf("invalid kcl_options: %v", test_settings_yaml.CmdArgs)
-			}
-		}
-	}
-
-	return nil
-}
diff --git a/pkg/tools/validate/validate.go b/pkg/tools/validate/validate.go
index 3e1ef08..93b661a 100644
--- a/pkg/tools/validate/validate.go
+++ b/pkg/tools/validate/validate.go
@@ -3,6 +3,8 @@
 package validate
 
 import (
+	"errors"
+
 	"kcl-lang.io/kcl-go/pkg/service"
 	"kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
 )
@@ -28,5 +30,9 @@ func ValidateCode(data, code string, opt *ValidateOptions) (ok bool, err error)
 	if err != nil {
 		return false, err
 	}
-	return resp.Success, nil
+	var e error = nil
+	if resp.ErrMessage != "" {
+		e = errors.New(resp.ErrMessage)
+	}
+	return resp.Success, e
 }


Test patch:
diff --git a/pkg/tools/validate/validate_test.go b/pkg/tools/validate/validate_test.go
index adee04f..5537de3 100644
--- a/pkg/tools/validate/validate_test.go
+++ b/pkg/tools/validate/validate_test.go
@@ -3,6 +3,7 @@
 package validate
 
 import (
+	"strings"
 	"testing"
 )
 
@@ -24,3 +25,21 @@ schema Person:
 		t.Fatalf("expect: %q, got False", "True")
 	}
 }
+
+func TestValidateCodeFail(t *testing.T) {
+	data := `{"k": "value"}`
+	code := `
+schema Person:
+    key: str
+
+    check:
+        "value" in key  # 'key' is required and 'key' must contain "value"
+`
+
+	_, err := ValidateCode(data, code, nil)
+	if err == nil {
+		t.Fatalf("expect validation error")
+	} else if !strings.Contains(err.Error(), "error") {
+		t.Fatalf("expect validation error, got %s", err.Error())
+	}
+}