validator

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: MIT Imports: 12 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 ListAvailableSchemas

func ListAvailableSchemas() []string

ListAvailableSchemas returns a list of all available schema names.

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