validation

package
v2.28.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParsingMetric       = errCommonValidation("ParsePoint", `Error parsing "metric" from JSON.`, "C01")
	ErrParsingTimestamp    = errCommonValidation("ParsePoint", `Error parsing "timestamp" from JSON.`, "C02")
	ErrParsingValue        = errCommonValidation("ParsePoint", `Error parsing "value" from JSON.`, "C03")
	ErrParsingText         = errCommonValidation("ParsePoint", `Error parsing "text" from JSON.`, "C04")
	ErrParsingTagKey       = errCommonValidation("ParsePoint", `Error parsing tag key from JSON.`, "C05")
	ErrParsingTagValue     = errCommonValidation("ParsePoint", `Error parsing tag value from JSON.`, "C06")
	ErrNumberTypeExpected  = errCommonValidation("ValidateType", `Wrong Format: Field "value" is required.`, "C07")
	ErrTextTypeExpected    = errCommonValidation("ValidateType", `Wrong Format: Field "text" is required.`, "C08")
	ErrMaxTextValueSize    = errCommonValidation("ValidateType", `Wrong Format: Field "text" has exceeded the maximum number of characters allowed`, "C09")
	ErrNoTags              = errCommonValidation("ValidateTags", `Wrong Format: At least one tag is required.`, "C10")
	ErrDuplicatedTags      = errCommonValidation("ValidateTags", `Wrong Format: Duplicated tags.`, "C11")
	ErrNoUserTags          = errCommonValidation("ValidateTags", `Wrong Format: At least one tag other than "ksid" and "ttl" is required.`, "C12")
	ErrNoKeysetTag         = errCommonValidation("ValidateKeyset", `Wrong Format: Tag "ksid" is required.`, "C13")
	ErrInvalidKeysetFormat = errCommonValidation("ValidateKeyset", `Wrong Format: Field "ksid" has a invalid format.`, "C14")
	ErrInvalidTagKey       = errCommonValidation("ValidateProperty", `Wrong Format: Tag key has a invalid format.`, "C15")
	ErrInvalidTagValue     = errCommonValidation("ValidateProperty", `Wrong Format: Tag value has a invalid format.`, "C16")
	ErrInvalidMetric       = errCommonValidation("ValidateProperty", `Wrong Format: Field "metric" (%s) is not well formed.`, "C17")
	ErrInvalidPropertyType = errCommonValidation("ValidateProperty", `Property type is not mapped`, "C18")
	ErrInvalidTTLValue     = errCommonValidation("ParseTTL", `Wrong Format: Tag "ttl" must be a positive number.`, "C19")
	ErrInexistentKeyset    = errCommonValidation("ValidateKeyset", `Keyset not exists.`, "C20")
	ErrMalformedJSON       = errCommonValidation("ParsePoint", `JSON is malformed.`, "C21")
	ErrInvalidTimestamp    = errCommonValidation("ValidateTimestamp", `Wrong Format: timestamp has a invalid format.`, "C22")
	ErrReadingJSONBytes    = errCommonValidation("ParsePointArray", "Error reading JSON bytes.", "C23")
)

Functions

func NewValidationError

func NewValidationError(function, message string, err error, errCode string) gobol.Error

NewValidationError - creates a new validation error

Types

type PropertyType

type PropertyType uint8

PropertyType - type

const (
	// TagKeyType - the tag identifier
	TagKeyType PropertyType = 1
	// TagValueType - the tag identifier
	TagValueType PropertyType = 2
	// MetricType - the metric identifier
	MetricType PropertyType = 3
)

type Service

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

Service - the validation structure

func New

func New(configuration *structs.ValidationConfiguration, metadataStorage *metadata.Storage, keyspaceTTLMap map[int]string, timelineManager *tlmanager.Instance) (*Service, error)

New - creates a new validation instance

func (*Service) GetDefaultTTLTag

func (v *Service) GetDefaultTTLTag() (*structs.TSDBTag, int)

GetDefaultTTLTag - returns the default TTL tag and its integer value

func (*Service) ParseTTL

func (v *Service) ParseTTL(value string) (int, string, gobol.Error)

ParseTTL - parses the TTL and returns its int value

func (*Service) StatsValidationError

func (v *Service) StatsValidationError(function, keyset, ip string, sourceType *constants.SourceType, gerr gobol.Error)

StatsValidationError - accumulates validation data

func (*Service) ValidateKeyset

func (v *Service) ValidateKeyset(keyset string) gobol.Error

ValidateKeyset - validates the keyset

func (*Service) ValidateProperty

func (v *Service) ValidateProperty(value string, propertyType PropertyType) gobol.Error

ValidateProperty - validates the property value

func (*Service) ValidateTags

func (v *Service) ValidateTags(p *structs.TSDBpoint) gobol.Error

ValidateTags - validates the tags from the point

func (*Service) ValidateTimestamp

func (v *Service) ValidateTimestamp(timestamp int64) (int64, gobol.Error)

ValidateTimestamp - parses the timestamp

func (*Service) ValidateType

func (v *Service) ValidateType(p *structs.TSDBpoint, number bool) gobol.Error

ValidateType - validates the point type

Jump to

Keyboard shortcuts

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