hl7v2

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 14 Imported by: 0

README

hl7v2

This repository is under heavy development. The API is not stable and may change at any time. Use at your own risk until proper documentation and a v1 release is made.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEncodingTooShort = errors.New("invalid delimiters, encoding chars must be at least 5 bytes")
	ErrEncodingInvalid  = errors.New("invalid encoding chars")
)
View Source
var (
	ErrMsgLength       = errors.New("invalid message: message length must be at least 8 bytes")
	ErrElementNotFound = errors.New("element not found")
	ErrValueNotFound   = errors.New("value not found")
)

Functions

func AckRawMessage

func AckRawMessage(msg []byte) ([]byte, error)

func Marshal

func Marshal(v any) ([]byte, error)

func Unmarshal

func Unmarshal(msg Queryable, v any) error

Types

type Acknowledgement

type Acknowledgement struct {
	MessageHeader
	Code             string
	ControlID        string
	Message          string
	ExpectedSequence string
	DelayedAckType   string
	ErrorCondition   string
}

type AcknowledgmentCode

type AcknowledgmentCode int
const (
	AckUnknown           AcknowledgmentCode = iota //UN
	AckApplicationAccept                           //AA
	AckApplicationError                            //AE
	AckApplicationReject                           //AR
	AckCommitAccept                                //CA
	AckCommitError                                 //CE
	AckCommitReject                                //CR
)

type Component

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

func NewComponent

func NewComponent(parent Element, pos int, raw RawComponent) *Component

func (*Component) Append

func (c *Component) Append(ne Element) error

func (*Component) Children

func (c *Component) Children() []Element

func (*Component) Delimiters

func (c *Component) Delimiters() *Delimiters

func (*Component) Encode

func (c *Component) Encode() ([]byte, error)

func (*Component) GetLocation

func (c *Component) GetLocation(loc query.Location) (Element, error)

func (*Component) Header

func (c *Component) Header() *MessageHeader

func (*Component) Length

func (c *Component) Length() int

func (*Component) Location

func (c *Component) Location() query.Location

func (*Component) Name

func (c *Component) Name() string

func (*Component) Parent

func (c *Component) Parent() Element

func (*Component) Position

func (c *Component) Position() int

func (*Component) SetLocation

func (c *Component) SetLocation(loc query.Location, val Value) error

func (*Component) Subcomponent

func (c *Component) Subcomponent(index int) (*Subcomponent, error)

func (*Component) Subcomponents

func (c *Component) Subcomponents() []*Subcomponent

func (*Component) Type

func (c *Component) Type() ElementType

func (*Component) Value

func (c *Component) Value(escape ...bool) Value

type Condition

type Condition struct {
	Name  string
	Check ConditionFunc
}

func Has

func Has(q string) (*Condition, error)

func ValueContains

func ValueContains(q, v string) (*Condition, error)

func ValueContainsAny

func ValueContainsAny(q string, v ...string) (*Condition, error)

type ConditionFunc

type ConditionFunc func(Element) bool

type Delimiter

type Delimiter byte

Delimiter is a byte representation of a single delimiter

func (Delimiter) Byte

func (d Delimiter) Byte() byte

func (Delimiter) Bytes

func (d Delimiter) Bytes() []byte

func (Delimiter) String

func (d Delimiter) String() string

type DelimiterType

type DelimiterType int

Type is an enum of valid delimiters

const (
	InvalidDelimiter      DelimiterType = iota //invalid
	SegmentDelimiter                           //segment
	FieldDelimiter                             //field
	RepetitionDelimiter                        //repetition
	ComponentDelimiter                         //component
	SubcomponentDelimiter                      //subcomponent
	EscapeDelimiter                            //escape
	TruncationDelimiter                        //truncation

)

func DelimiterTypeString

func DelimiterTypeString(s string) (DelimiterType, error)

DelimiterTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func DelimiterTypeValues

func DelimiterTypeValues() []DelimiterType

DelimiterTypeValues returns all values of the enum

func (DelimiterType) IsADelimiterType

func (i DelimiterType) IsADelimiterType() bool

IsADelimiterType returns "true" if the value is listed in the enum definition. "false" otherwise

func (DelimiterType) String

func (i DelimiterType) String() string

type Delimiters

type Delimiters struct {
	Segment      Delimiter
	Field        Delimiter
	Repetition   Delimiter
	Component    Delimiter
	Subcomponent Delimiter
	Escape       Delimiter
	Truncation   Delimiter
}

Delimiters holds the message delimiters

func DefaultDelimiters

func DefaultDelimiters() *Delimiters

DefaultDelimiters returns the default delimiters

func NewDelimiters

func NewDelimiters(setters ...SetDelimiter) *Delimiters

func ParseDelimiters

func ParseDelimiters(b []byte) (*Delimiters, error)

func (*Delimiters) EncodingCharsValue

func (d *Delimiters) EncodingCharsValue() Value

func (*Delimiters) Escaper

func (d *Delimiters) Escaper() *Escaper

func (*Delimiters) FieldSeparatorValue

func (d *Delimiters) FieldSeparatorValue() Value

func (*Delimiters) Join

func (d *Delimiters) Join(b [][]byte, typ DelimiterType) []byte

func (*Delimiters) Split

func (d *Delimiters) Split(b []byte, typ DelimiterType) [][]byte

type Element

type Element interface {
	Type() ElementType
	Name() string
	Delimiters() *Delimiters
	Header() *MessageHeader
	Parent() Element
	Children() []Element
	Length() int
	Position() int
	Location() query.Location
	Value(escape ...bool) Value
	GetLocation(query.Location) (Element, error)
	SetLocation(query.Location, Value) error
	Append(Element) error
	Encode() ([]byte, error)
}

Element interface for HL7 elements

type ElementIterator

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

func NewIterator

func NewIterator(el Element) *ElementIterator

func (*ElementIterator) Next

func (i *ElementIterator) Next() Element

type ElementType

type ElementType int

ElementType is an enum of valid element types

const (
	ElementInvalid      ElementType = iota //invalid
	ElementBatch                           //batch
	ElementFile                            //file
	ElementMessage                         //message
	ElementSegmentGroup                    //group
	ElementSegment                         //segment
	ElementField                           //field
	ElementRepetition                      //repetition
	ElementComponent                       //component
	ElementSubcomponent                    //subcomponent
)

func ElementTypeString

func ElementTypeString(s string) (ElementType, error)

ElementTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ElementTypeValues

func ElementTypeValues() []ElementType

ElementTypeValues returns all values of the enum

func (ElementType) IsAElementType

func (i ElementType) IsAElementType() bool

IsAElementType returns "true" if the value is listed in the enum definition. "false" otherwise

func (ElementType) String

func (i ElementType) String() string

type Escaper

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

func NewEscaper

func NewEscaper(delims *Delimiters) *Escaper

func (*Escaper) Escape

func (e *Escaper) Escape(b []byte) []byte

func (*Escaper) Unescape

func (e *Escaper) Unescape(b []byte) []byte

type Field

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

func NewField

func NewField(parent Element, pos int, raw RawField) *Field

func (*Field) Append

func (f *Field) Append(el Element) error

func (*Field) Children

func (f *Field) Children() []Element

func (*Field) Delimiters

func (f *Field) Delimiters() *Delimiters

func (*Field) Encode

func (f *Field) Encode() ([]byte, error)

func (*Field) GetLocation

func (f *Field) GetLocation(loc query.Location) (Element, error)

func (*Field) Header

func (f *Field) Header() *MessageHeader

func (*Field) Length

func (f *Field) Length() int

func (*Field) Location

func (f *Field) Location() query.Location

func (*Field) Name

func (f *Field) Name() string

func (*Field) Parent

func (f *Field) Parent() Element

func (*Field) Position

func (f *Field) Position() int

func (*Field) Repetition

func (f *Field) Repetition(index int) (*Repetition, error)

func (*Field) Repetitions

func (f *Field) Repetitions() []*Repetition

func (*Field) SetLocation

func (f *Field) SetLocation(loc query.Location, val Value) error

func (*Field) Type

func (f *Field) Type() ElementType

func (*Field) Value

func (f *Field) Value(escape ...bool) Value
type Header interface {
	Type() HeaderType
	Delimiters() *Delimiters
	SendingApplication() string
	SendingFacility() string
	ReceivingApplication() string
	ReceivingFacility() string
	DateTime() time.Time
	Security() string
}

func NewHeader

func NewHeader(typ HeaderType) Header

type HeaderType

type HeaderType int

HeaderType is an enum type for valid header types

const (
	HeaderTypeMessage HeaderType = iota //MSH
	HeaderTypeFile                      //FHS
	HeaderTypeBatch                     //BHS
)

func HeaderTypeString

func HeaderTypeString(s string) (HeaderType, error)

HeaderTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func HeaderTypeValues

func HeaderTypeValues() []HeaderType

HeaderTypeValues returns all values of the enum

func (HeaderType) IsAHeaderType

func (i HeaderType) IsAHeaderType() bool

IsAHeaderType returns "true" if the value is listed in the enum definition. "false" otherwise

func (HeaderType) String

func (i HeaderType) String() string

func (HeaderType) Trailer

func (t HeaderType) Trailer() TrailerType

type Marshaler

type Marshaler interface {
	MarshalHL7() ([]byte, error)
}

type Message

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

func NewMessage

func NewMessage(r io.Reader, opts ...ParserOption) (*Message, error)

func NewMessageFromBytes

func NewMessageFromBytes(b []byte, opts ...ParserOption) (*Message, error)

func NewMessageFromFile

func NewMessageFromFile(f string, opts ...ParserOption) (*Message, error)

func (*Message) Append

func (m *Message) Append(el Element) error

func (*Message) Children

func (m *Message) Children() []Element

func (*Message) Delimiters

func (m *Message) Delimiters() *Delimiters

func (*Message) Encode

func (m *Message) Encode() ([]byte, error)

func (*Message) GetLocation

func (m *Message) GetLocation(loc query.Location) (Element, error)

func (*Message) HasSegment

func (m *Message) HasSegment(id string) bool

func (*Message) Header

func (m *Message) Header() *MessageHeader

func (*Message) Length

func (m *Message) Length() int

func (*Message) Location

func (m *Message) Location() query.Location

func (*Message) Name

func (m *Message) Name() string

func (*Message) Parent

func (m *Message) Parent() Element

func (*Message) Position

func (m *Message) Position() int

func (*Message) Query

func (m *Message) Query(q string) (Element, error)

func (*Message) QueryValue

func (m *Message) QueryValue(q string) (*Value, error)

func (*Message) Raw

func (m *Message) Raw() (*RawMessage, error)

func (*Message) Schema

func (m *Message) Schema() (*schema.Message, error)

func (*Message) Segment

func (m *Message) Segment(name string, idx ...int) (*Segment, error)

func (*Message) SegmentList

func (m *Message) SegmentList() []string

func (*Message) Segments

func (m *Message) Segments(id ...string) []*Segment

func (*Message) Select

func (m *Message) Select(q string) ([]Element, error)

func (*Message) SetLocation

func (m *Message) SetLocation(loc query.Location, val Value) error

func (*Message) Type

func (m *Message) Type() ElementType

func (*Message) Value

func (m *Message) Value(escape ...bool) Value

type MessageHeader

type MessageHeader struct {
	Delimiters                    *Delimiters `json:"delimiters" hl7:"MSH.1"`
	SendingApplication            string      `json:"sending_application" hl7:"MSH.3"`
	SendingFacility               string      `json:"sending_facility" hl7:"MSH.4"`
	ReceivingApplication          string      `json:"receiving_application" hl7:"MSH.5"`
	ReceivingFacility             string      `json:"receiving_facility" hl7:"MSH.6"`
	MessageDate                   time.Time   `json:"message_date" hl7:"MSH.7"`
	Security                      string      `json:"security" hl7:"MSH.8"`
	MessageCode                   string      `json:"type" hl7:"MSH.9.1"`
	TriggerEvent                  string      `json:"event_trigger" hl7:"MSH.9.2"`
	MessageStructure              string      `json:"message_structure" hl7:"MSH.9.3"`
	ControlID                     string      `json:"control_id" hl7:"MSH.10"`
	ProcessingID                  string      `json:"processing_id" hl7:"MSH.11"`
	VersionID                     string      `json:"version_id" hl7:"MSH.12"`
	SequenceNumber                int         `json:"sequence_number" hl7:"MSH.13"`
	ContinuationPointer           string      `json:"continuation_pointer" hl7:"MSH.14"`
	AcceptAcknowledgmentType      string      `json:"accept_acknowledgment" hl7:"MSH.15"`
	ApplicationAcknowledgmentType string      `json:"application_acknowledgment" hl7:"MSH.16"`
	CountryCode                   string      `json:"country_code" hl7:"MSH.17"`
	CharacterSet                  string      `json:"character_set" hl7:"MSH.18"`
	PrincipalLanguage             string      `json:"principal_language" hl7:"MSH.19"`
	AlternateCharacterSet         string      `json:"alternate_character_set" hl7:"MSH.20"`
	ProfileID                     string      `json:"profile_id" hl7:"MSH.21"`
	SendingResponsibleOrgCode     string      `json:"sending_responsible_org_code" hl7:"MSH.22"`
	ReceivingResponsibleOrgCode   string      `json:"receiving_responsible_org_code" hl7:"MSH.23"`
	SendingNetworkAddress         string      `json:"sending_network_address" hl7:"MSH.24"`
	ReceivingNetworkAddress       string      `json:"receiving_network_address" hl7:"MSH.25"`
}

func (*MessageHeader) MarshalHL7

func (h *MessageHeader) MarshalHL7() ([]byte, error)

func (*MessageHeader) MessageType

func (h *MessageHeader) MessageType() MessageType

type MessageType

type MessageType struct {
	Code      string
	Event     string
	Structure string
}

func ParseMessageType

func ParseMessageType(s string, delims *Delimiters) (MessageType, error)

func (MessageType) Encode

func (t MessageType) Encode(delims *Delimiters) []byte

func (MessageType) String

func (t MessageType) String() string

type ParserOption

type ParserOption func(*ParserOptions)

func FixLineEndings

func FixLineEndings() ParserOption

func PreParse

func PreParse(t RawTransform) ParserOption

type ParserOptions

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

func NewParserOptions

func NewParserOptions(opts ...ParserOption) *ParserOptions

type Queryable

type Queryable interface {
	Delimiters() *Delimiters
	QueryValue(q string) (*Value, error)
}

type RawComponent

type RawComponent []RawSubcomponent

func (RawComponent) Query

func (c RawComponent) Query(loc query.Location, delims ...*Delimiters) (*Value, error)

func (RawComponent) String

func (c RawComponent) String(delims ...*Delimiters) string

func (RawComponent) Value

func (c RawComponent) Value(delims ...*Delimiters) Value

type RawField

type RawField []RawRepetition

func (RawField) Query

func (f RawField) Query(loc query.Location, delims ...*Delimiters) (*Value, error)

func (RawField) String

func (f RawField) String(delims ...*Delimiters) string

func (RawField) Value

func (f RawField) Value(delims ...*Delimiters) Value

type RawMessage

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

func NewRawMessage

func NewRawMessage(delims *Delimiters, segs ...RawSegment) *RawMessage

func ParseRaw

func ParseRaw(b []byte, opts ...ParserOption) (*RawMessage, error)

func ReadRaw

func ReadRaw(r io.Reader, opts ...ParserOption) (*RawMessage, error)

func (*RawMessage) Decode

func (m *RawMessage) Decode() (*Message, error)

func (*RawMessage) Delimiters

func (m *RawMessage) Delimiters() *Delimiters

func (*RawMessage) JSON

func (m *RawMessage) JSON(pretty ...bool) ([]byte, error)

func (*RawMessage) QueryValue

func (m *RawMessage) QueryValue(q string) (*Value, error)

func (*RawMessage) Segments

func (m *RawMessage) Segments(id ...string) []RawSegment

func (*RawMessage) ToMessage

func (m *RawMessage) ToMessage() (*Message, error)

func (*RawMessage) Value

func (m *RawMessage) Value() Value

type RawRepetition

type RawRepetition []RawComponent

func (RawRepetition) Query

func (r RawRepetition) Query(loc query.Location, delims ...*Delimiters) (*Value, error)

func (RawRepetition) String

func (r RawRepetition) String(delims ...*Delimiters) string

func (RawRepetition) Value

func (r RawRepetition) Value(delims ...*Delimiters) Value

type RawSegment

type RawSegment []RawField

func (RawSegment) ID

func (s RawSegment) ID() string

func (RawSegment) Query

func (s RawSegment) Query(loc query.Location, delims ...*Delimiters) (*Value, error)

func (RawSegment) String

func (s RawSegment) String(delims ...*Delimiters) string

func (RawSegment) Value

func (s RawSegment) Value(delims ...*Delimiters) Value

type RawSegmentGroup

type RawSegmentGroup []RawSegment

type RawSubcomponent

type RawSubcomponent []byte

func (RawSubcomponent) String

func (s RawSubcomponent) String() string

func (RawSubcomponent) Value

func (s RawSubcomponent) Value() Value

type RawTransform

type RawTransform func([]byte) ([]byte, error)

type Repetition

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

func NewRepetition

func NewRepetition(parent Element, pos int, raw RawRepetition) *Repetition

func (*Repetition) Append

func (r *Repetition) Append(el Element) error

func (*Repetition) Children

func (r *Repetition) Children() []Element

func (*Repetition) Component

func (r *Repetition) Component(idx int) (*Component, error)

func (*Repetition) Components

func (r *Repetition) Components() []*Component

func (*Repetition) Delimiters

func (r *Repetition) Delimiters() *Delimiters

func (*Repetition) Encode

func (r *Repetition) Encode() ([]byte, error)

func (*Repetition) GetLocation

func (r *Repetition) GetLocation(loc query.Location) (Element, error)

func (*Repetition) Header

func (r *Repetition) Header() *MessageHeader

func (*Repetition) Length

func (r *Repetition) Length() int

func (*Repetition) Location

func (r *Repetition) Location() query.Location

func (*Repetition) Name

func (r *Repetition) Name() string

func (*Repetition) Parent

func (r *Repetition) Parent() Element

func (*Repetition) Position

func (r *Repetition) Position() int

func (*Repetition) SetLocation

func (r *Repetition) SetLocation(loc query.Location, val Value) error

func (*Repetition) Type

func (r *Repetition) Type() ElementType

func (*Repetition) Value

func (r *Repetition) Value(escape ...bool) Value

type Segment

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

func NewSegment

func NewSegment(parent Element, pos int, raw RawSegment) *Segment

func (*Segment) Append

func (s *Segment) Append(el Element) error

func (*Segment) Children

func (s *Segment) Children() []Element

func (*Segment) Delimiters

func (s *Segment) Delimiters() *Delimiters

func (*Segment) Encode

func (s *Segment) Encode() ([]byte, error)

func (*Segment) Field

func (s *Segment) Field(index int) (*Field, error)

func (*Segment) Fields

func (s *Segment) Fields() []*Field

func (*Segment) GetLocation

func (s *Segment) GetLocation(loc query.Location) (Element, error)

func (*Segment) Header

func (s *Segment) Header() *MessageHeader

func (*Segment) Index

func (s *Segment) Index() int

func (*Segment) Length

func (s *Segment) Length() int

func (*Segment) Location

func (s *Segment) Location() query.Location

func (*Segment) Name

func (s *Segment) Name() string

func (*Segment) Parent

func (s *Segment) Parent() Element

func (*Segment) Position

func (s *Segment) Position() int

func (*Segment) SetLocation

func (s *Segment) SetLocation(loc query.Location, val Value) error

func (*Segment) Type

func (s *Segment) Type() ElementType

func (*Segment) Value

func (s *Segment) Value(escape ...bool) Value

type SegmentGroup

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

func (*SegmentGroup) Children

func (g *SegmentGroup) Children() []Element

func (*SegmentGroup) Delimiters

func (g *SegmentGroup) Delimiters() *Delimiters

func (*SegmentGroup) GetLocation

func (g *SegmentGroup) GetLocation(_ query.Location) (Element, error)

func (*SegmentGroup) Length

func (g *SegmentGroup) Length() int

func (*SegmentGroup) Location

func (g *SegmentGroup) Location() query.Location

func (*SegmentGroup) Name

func (g *SegmentGroup) Name() string

func (*SegmentGroup) Parent

func (g *SegmentGroup) Parent() Element

func (*SegmentGroup) Position

func (g *SegmentGroup) Position() int

func (*SegmentGroup) Type

func (g *SegmentGroup) Type() ElementType

func (*SegmentGroup) Value

func (g *SegmentGroup) Value(escape ...bool) Value

type SetDelimiter

type SetDelimiter func(*Delimiters)

func SetComponent

func SetComponent(delim Delimiter) SetDelimiter

func SetField

func SetField(delim Delimiter) SetDelimiter

func SetRepetition

func SetRepetition(delim Delimiter) SetDelimiter

func SetSegment

func SetSegment(delim Delimiter) SetDelimiter

func SetSubcomponent

func SetSubcomponent(delim Delimiter) SetDelimiter

func SetTruncation

func SetTruncation(delim Delimiter) SetDelimiter

type Subcomponent

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

func NewEmptySubcomponent

func NewEmptySubcomponent() *Subcomponent

func NewSubcomponent

func NewSubcomponent(parent Element, pos int, v Value) *Subcomponent

func NewSubcomponentValue

func NewSubcomponentValue(val Value) *Subcomponent

func (*Subcomponent) Append

func (el *Subcomponent) Append(_ Element) error

func (*Subcomponent) Children

func (el *Subcomponent) Children() []Element

func (*Subcomponent) Delimiters

func (el *Subcomponent) Delimiters() *Delimiters

func (*Subcomponent) Encode

func (el *Subcomponent) Encode() ([]byte, error)

func (*Subcomponent) GetLocation

func (el *Subcomponent) GetLocation(loc query.Location) (Element, error)

func (*Subcomponent) Header

func (el *Subcomponent) Header() *MessageHeader

func (*Subcomponent) Length

func (el *Subcomponent) Length() int

func (*Subcomponent) Location

func (el *Subcomponent) Location() query.Location

func (*Subcomponent) Name

func (el *Subcomponent) Name() string

func (*Subcomponent) Parent

func (el *Subcomponent) Parent() Element

func (*Subcomponent) Position

func (el *Subcomponent) Position() int

func (*Subcomponent) SetLocation

func (el *Subcomponent) SetLocation(loc query.Location, val Value) error

func (*Subcomponent) Type

func (el *Subcomponent) Type() ElementType

func (*Subcomponent) Value

func (el *Subcomponent) Value(escape ...bool) Value

type TrailerType

type TrailerType int
const (
	TrailerTypeNone  TrailerType = iota //_
	TrailerTypeFile                     //FTS
	TrailerTypeBatch                    //BTS
)

func TrailerTypeString

func TrailerTypeString(s string) (TrailerType, error)

TrailerTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func TrailerTypeValues

func TrailerTypeValues() []TrailerType

TrailerTypeValues returns all values of the enum

func (TrailerType) IsATrailerType

func (i TrailerType) IsATrailerType() bool

IsATrailerType returns "true" if the value is listed in the enum definition. "false" otherwise

func (TrailerType) String

func (i TrailerType) String() string

type Unmarshaler

type Unmarshaler interface {
	UnmarshalHL7(msg Queryable, v any) error
}

type ValidationFunc

type ValidationFunc func(Element) ValidationResult

func (ValidationFunc) Validate

func (f ValidationFunc) Validate(e Element) ValidationResult

type ValidationResult

type ValidationResult struct {
	Valid  bool
	Errors []error
}

func ValidateMessageSchema

func ValidateMessageSchema(el Element) ValidationResult

func ValidateSegmentSchema

func ValidateSegmentSchema(el Element) ValidationResult

type Validator

type Validator interface {
	Validate(Element) ValidationResult
}

type Value

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

func MarshalValue

func MarshalValue(v any) Value

func NewDateTimeValue

func NewDateTimeValue(date time.Time) Value

func NewDateValue

func NewDateValue(date time.Time) Value

func NewEmptyValue

func NewEmptyValue() Value

func NewIntValue

func NewIntValue(v int) Value

func NewStringValue

func NewStringValue(v string) Value

func NewValue

func NewValue(v []byte) Value

func UnescapeElement

func UnescapeElement(el Element) (Value, error)

func UnescapeValue

func UnescapeValue(v []byte, delims *Delimiters) Value

func (Value) Bind

func (v Value) Bind(val any) error

func (Value) Bool

func (v Value) Bool() bool

func (Value) Bytes

func (v Value) Bytes() []byte

func (Value) Date

func (v Value) Date() time.Time

TODO: support for timezone adjustments

func (Value) Empty

func (v Value) Empty() bool

func (Value) Escape

func (v Value) Escape(delims *Delimiters) Value

func (Value) Float64

func (v Value) Float64() float64

func (Value) Int

func (v Value) Int() int

func (Value) String

func (v Value) String() string

func (Value) Unescape

func (v Value) Unescape(delims *Delimiters) Value

type ValueTransform

type ValueTransform func(el Element) (Value, error)

type Version

type Version int
const (
	VersionUnknown Version = iota //unknown
	Version21                     //2.1
	Version22                     //2.2
	Version23                     //2.3
	Version231                    //2.3.1
	Version24                     //2.4
	Version25                     //2.5
	Version251                    //2.5.1
	Version26                     //2.6
	Version27                     //2.7
	Version271                    //2.7.1
	Version28                     //2.8
	Version281                    //2.8.1
	Version282                    //2.8.2
	Version29                     //2.9
)

func VersionString

func VersionString(s string) (Version, error)

VersionString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func VersionValues

func VersionValues() []Version

VersionValues returns all values of the enum

func (Version) IsAVersion

func (i Version) IsAVersion() bool

IsAVersion returns "true" if the value is listed in the enum definition. "false" otherwise

func (Version) String

func (i Version) String() string

Jump to

Keyboard shortcuts

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