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