schema

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package schema provides schemas and validation functions for it.

Index

Constants

View Source
const (
	// DataPerPDVLimit is limit how much data we allow per PDV.
	DataPerPDVLimit = 20
	// PDVDataSizeLimit is limit to PDVData's size.
	PDVDataSizeLimit = 8 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PDV

type PDV struct {
	Version PDVVersion `json:"version"`

	PDV PDVObject `json:"pdv"`
}

PDV is main data object.

func (PDV) MarshalJSON

func (p PDV) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*PDV) UnmarshalJSON

func (p *PDV) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type PDVData

type PDVData interface {
	Validate

	Version() PDVVersion
	Type() PDVType
}

PDVData is interface for all data types.

type PDVDataCookieV1

type PDVDataCookieV1 struct {
	Name           string `json:"name"`
	Value          string `json:"value"`
	Domain         string `json:"domain"`
	Path           string `json:"path"`
	SameSite       string `json:"same_site"`
	HostOnly       bool   `json:"host_only"`
	Secure         bool   `json:"secure"`
	ExpirationDate uint64 `json:"expiration_date,omitempty"`
}

PDVDataCookieV1 is PDVData implementation for Cookies(according to https://developer.chrome.com/extensions/cookies) with version v1.

func (PDVDataCookieV1) MarshalJSON

func (d PDVDataCookieV1) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (PDVDataCookieV1) Type

func (PDVDataCookieV1) Type() PDVType

Type ...

func (*PDVDataCookieV1) Validate

func (d *PDVDataCookieV1) Validate() bool

Validate ...

func (PDVDataCookieV1) Version

func (PDVDataCookieV1) Version() PDVVersion

Version ...

type PDVDataMeta

type PDVDataMeta struct {
	PDVVersion PDVVersion `json:"version"`
	PDVType    PDVType    `json:"type"`
}

PDVDataMeta contains common information about data.

type PDVObject

type PDVObject interface {
	Validate

	Version() PDVVersion
}

PDVObject is interface for all versions objects.

type PDVObjectMetaV1

type PDVObjectMetaV1 struct {
	// Website information
	Host string `json:"domain"`
	Path string `json:"path"`
}

PDVObjectMetaV1 is PDVObjectV1 meta data.

type PDVObjectV1

type PDVObjectV1 struct {
	PDVObjectMetaV1

	Data []PDVData `json:"data"`
}

PDVObjectV1 is PDVObject implementation with v1 version.

func (*PDVObjectV1) UnmarshalJSON

func (o *PDVObjectV1) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

func (*PDVObjectV1) Validate

func (o *PDVObjectV1) Validate() bool

Validate ...

func (*PDVObjectV1) Version

func (o *PDVObjectV1) Version() PDVVersion

Version ...

type PDVType

type PDVType string

PDVType represents data type.

const (
	// PDVCookieType ...
	PDVCookieType PDVType = "cookie"
)

type PDVVersion

type PDVVersion string

PDVVersion represents version.

const (
	// PDVv1 ...
	PDVv1 PDVVersion = "v1"
)

type Validate

type Validate interface {
	Validate() bool
}

Validate ...

Jump to

Keyboard shortcuts

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