Skip to main content

Native functions

info

If you want new functions, please create issues.

caution

We don't write the document of each native functions because we have ported too many functions from Go standard library to maintain the document of them. Please see GoDoc and API design.

API design

Please see API design.

jsonschema.Validate

func(schema, v any) error

https://pkg.go.dev/github.com/santhosh-tekuri/jsonschema/v5#Schema.Validate

e.g.

local schema = import 'main_config_schema.json'; // Import JSON Schema
local validateJSONSchema = std.native('jsonschema.Validate');
local vr = validateJSONSchema(schema, param.config); // Validate param.config with JSON Schema main_config_shema.json

Validate validates v with JSON Schema schema and returns the result. schema is a object representing a JSON Schema. You can define it in Jsonnet or read a JSON Schema with import. Validate returns a error message (string) if something is wrong, or returns a detailed error object if v violates JSON Schema. If there is no violation, Validate returns null.

url.Parse

https://pkg.go.dev/net/url#Parse

This function converts *url.URL to an object and returns it.

e.g.

[
{
"Scheme": "http",
"Opaque": "",
"Host": "example.com",
"Path": "/foo/bar",
"RawPath": "",
"OmitHost": false,
"ForceQuery": false,
"RawQuery": "lang=en&tag=go",
"Fragment": "top",
"RawFragment": "",
"Query": {
"lang": ["en"],
"tag": ["go"],
},
},
null
]