validate

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONValidator

type JSONValidator struct {
	// contains filtered or unexported fields
}

func NewJSONValidator

func NewJSONValidator(opts ...JsonValidatorOption) (*JSONValidator, error)

NewJSONValidator creates a new instance to validate a JSON file against a document

func (*JSONValidator) Validate

func (v *JSONValidator) Validate() error

Validate checks the JSON document against the schema and returns an error if validation fails.

type JsonValidatorOption

type JsonValidatorOption func(*JSONValidator) error

JsonValidatorOption defines a functional option for configuring a JSONValidator instance.

func WithJSONDocument

func WithJSONDocument(doc []byte) JsonValidatorOption

WithJSONDocument sets the JSON document for the JSONValidator using the provided byte slice.

func WithJSONSchema

func WithJSONSchema(jsonSchema []byte) JsonValidatorOption

WithJSONSchema sets a JSON schema for the JSONValidator using the provided schema byte slice. It compiles the schema and attaches it to the validator instance. Returns an error if schema compilation fails.

func WithLogger

func WithLogger(logger *slog.Logger) JsonValidatorOption

WithLogger provides the logger to use

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL