Documentation
¶
Overview ¶
Package schema provides embedded PromptPack schema for offline validation.
Package schema provides embedded PromptPack schema and shared schema validation utilities.
Index ¶
Constants ¶
const DefaultSchemaURL = "https://promptpack.org/schema/latest/promptpack.schema.json"
DefaultSchemaURL is the canonical URL for the PromptPack schema.
const SchemaSourceEnvVar = "PROMPTKIT_SCHEMA_SOURCE"
SchemaSourceEnvVar is the environment variable to override schema source. Values: "local" (embedded), "remote" (fetch from URL), or a file path.
Variables ¶
This section is empty.
Functions ¶
func ExtractSchemaURL ¶
ExtractSchemaURL extracts the $schema URL from pack JSON data. Returns empty string if not present or invalid.
func GetEmbeddedSchema ¶
func GetEmbeddedSchema() string
GetEmbeddedSchema returns the embedded schema as a string.
func GetEmbeddedSchemaVersion ¶
GetEmbeddedSchemaVersion returns the version from the embedded schema.
func GetSchemaLoader ¶
func GetSchemaLoader(packSchemaURL string) (gojsonschema.JSONLoader, error)
GetSchemaLoader returns a gojsonschema loader for the PromptPack schema. Priority:
- If PROMPTKIT_SCHEMA_SOURCE is set to "local", use embedded schema
- If PROMPTKIT_SCHEMA_SOURCE is a file path, load from that file
- If PROMPTKIT_SCHEMA_SOURCE is "remote" and packSchemaURL is provided, fetch from that URL
- Otherwise, use embedded schema (default for offline support)
Types ¶
type ValidationError ¶ added in v1.3.2
ValidationError represents a single schema validation error with field-level detail.
func (ValidationError) Error ¶ added in v1.3.2
func (e ValidationError) Error() string
Error implements the error interface.
type ValidationResult ¶ added in v1.3.2
type ValidationResult struct {
Valid bool
Errors []ValidationError
}
ValidationResult contains the results of JSON schema validation.
func ConvertResult ¶ added in v1.3.2
func ConvertResult(result *gojsonschema.Result) *ValidationResult
ConvertResult converts a gojsonschema result into a ValidationResult.
func ValidateJSONAgainstLoader ¶ added in v1.3.2
func ValidateJSONAgainstLoader(jsonData []byte, schemaLoader gojsonschema.JSONLoader) (*ValidationResult, error)
ValidateJSONAgainstLoader validates raw JSON bytes against a schema provided as a gojsonschema.JSONLoader. This is the shared, low-level validation entry point used by Arena config validation (pkg/config), PromptPack validation (sdk/internal/pack), and the pack compiler (tools/packc).