validator

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidChat = errors.New("invalid chat")

ErrInvalidChat indicates the chat extension does not conform to the schema.

Functions

func EventPointXSD added in v0.3.1

func EventPointXSD() []byte

EventPointXSD returns the raw XSD bytes for the event point schema.

func ListAvailableSchemas

func ListAvailableSchemas() []string

ListAvailableSchemas returns a list of all available schema names.

func ResetForTest added in v0.3.1

func ResetForTest()

ResetForTest resets package state for testing.

func SetEventPointXSDForTest added in v0.3.3

func SetEventPointXSDForTest(data []byte)

SetEventPointXSDForTest sets the event point schema bytes for testing.

func SetMkTempForTest added in v0.3.1

func SetMkTempForTest(f func(string, string) (string, error))

SetMkTempForTest sets the MkdirTemp function for testing.

func SetWriteSchemasForTest added in v0.3.1

func SetWriteSchemasForTest(f func(string) error)

SetWriteSchemasForTest sets the schema writing function for testing.

func ValidateAgainstSchema

func ValidateAgainstSchema(name string, xml []byte) error

ValidateAgainstSchema validates XML against a named schema.

func ValidateChat

func ValidateChat(data []byte) error

ValidateChat parses and validates a __chat extension.

Types

type ChatSchema

type ChatSchema struct {
	XMLName xml.Name `xml:"__chat"`
	ID      string   `xml:"id,attr,omitempty"`
	Message string   `xml:"message,attr"`
	Sender  string   `xml:"sender,attr"`
}

ChatSchema defines the expected attributes for the __chat extension.

type Schema

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

Schema wraps a compiled XML Schema.

func Compile

func Compile(data []byte) (*Schema, error)

Compile compiles raw XSD bytes into a Schema.

func CompileFile

func CompileFile(path string) (*Schema, error)

CompileFile compiles an XSD schema from a file path.

func (*Schema) Free

func (s *Schema) Free()

Free releases resources associated with the schema.

func (*Schema) Validate

func (s *Schema) Validate(xml []byte) error

Validate validates XML bytes against the schema.

Jump to

Keyboard shortcuts

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