package
6.27.0+incompatible
Repository: https://github.com/clever/kayvee-go.git
Documentation: pkg.go.dev

# README

validator

-- import "gopkg.in/Clever/kayvee-go.v6/validator"

Usage

func ValidateJSONFormat

func ValidateJSONFormat(logLine string) error

ValidateJSONFormat returns a errors if the given string is not a valid JSON-formatted kayvee log line.

type InvalidJSONError

type InvalidJSONError struct {
}

InvalidJSONError is returned by ValidateJSONFormat for log lines that aren't valid JSON objects.

func (*InvalidJSONError) Error

func (e *InvalidJSONError) Error() string

type InvalidValueError

type InvalidValueError struct {
	Field string
	Value interface{}
}

InvalidValueError is returned for log lines containing a field with an invalid value.

func (*InvalidValueError) Error

func (e *InvalidValueError) Error() string

type InvalidValueTypeError

type InvalidValueTypeError struct {
	Field        string
	ExpectedType ValueType
}

InvalidValueTypeError is returned for log lines containing a field with an invalid value type.

func (*InvalidValueTypeError) Error

func (e *InvalidValueTypeError) Error() string

type MissingRequiredFieldError

type MissingRequiredFieldError struct {
	Field string
}

MissingRequiredFieldError is returned for log lines that don't contain a required field. NOTE: Certain fields are only required for specific log types.

func (*MissingRequiredFieldError) Error

func (e *MissingRequiredFieldError) Error() string

type ValueType

type ValueType string

ValueType represents the valuve type of a Kayvee field, where applicable.

const (
	StringType ValueType = "string"
	NumberType ValueType = "number"
)

Kayvee value types that are explicitly checked.

# Functions

ValidateJSONFormat returns a errors if the given string is not a valid JSON-formatted kayvee log line.

# Constants

Kayvee value types that are explicitly checked.
Kayvee value types that are explicitly checked.

# Structs

InvalidJSONError is returned by `ValidateJSONFormat` for log lines that aren't valid JSON objects.
InvalidValueError is returned for log lines containing a field with an invalid value.
InvalidValueTypeError is returned for log lines containing a field with an invalid value type.
MissingRequiredFieldError is returned for log lines that don't contain a required field.

# Type aliases

ValueType represents the valuve type of a Kayvee field, where applicable.