validator

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 5 Imported by: 0

README

validator

Table of contents

Summary

This package provides JSON schema-based validation for JSON, YAML, and arbitrary Go values.

Input types

The following input types are supported.

  • []byte - as JSON
  • []byte - as YAML
  • any

Design

Dependencies

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPkg = errors.New("validator")

ErrPkg a common package error.

Functions

This section is empty.

Types

type AnyValidator

type AnyValidator interface {
	ValidateAny(schema []byte, input any) ([]Error, error)
}

AnyValidator validator interface.

type DefaultValidator

type DefaultValidator struct{}

DefaultValidator is a Validator service.

func New

func New() *DefaultValidator

New validator factory function.

func (*DefaultValidator) ValidateAny

func (v *DefaultValidator) ValidateAny(schema []byte, input any) ([]Error, error)

ValidateAny can be used to validate any type.

func (*DefaultValidator) ValidateJSON

func (v *DefaultValidator) ValidateJSON(schema, input []byte) ([]Error, error)

ValidateJSON can be used to validate JSON value.

func (*DefaultValidator) ValidateYAML

func (v *DefaultValidator) ValidateYAML(schema, input []byte) ([]Error, error)

ValidateYAML can be used to validate JSON value.

type Error

type Error struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

Error represents a validation error found.

type JSONValidator

type JSONValidator interface {
	ValidateJSON(schema, input []byte) ([]Error, error)
}

JSONValidator validator interface.

type YAMLValidator

type YAMLValidator interface {
	ValidateYAML(schema, input []byte) ([]Error, error)
}

YAMLValidator validator interface.

Jump to

Keyboard shortcuts

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