ytypes

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2017 License: Apache-2.0 Imports: 16 Imported by: 668

Documentation

Overview

Package ytypes implements YANG type validation logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCaseSelected

func IsCaseSelected(schema *yang.Entry, value interface{}) (selected []string, errors []error)

IsCaseSelected reports whether a case with the given schema has been selected in the given value struct. The top level of the struct is checked, and any choices present in the schema are recursively followed to determine whether any case is selected for that choice schema subtree. It returns a slice with the names of all fields in the case that were selected.

func Unmarshal

func Unmarshal(schema *yang.Entry, parent interface{}, value interface{}) error

Unmarshal recursively unmarshals JSON data tree in value into the given parent, using the given schema. Any values already in the parent that are not present in value are preserved.

func Validate

func Validate(schema *yang.Entry, value interface{}, opts ...ygot.ValidationOption) util.Errors

Validate recursively validates the value of the given data tree struct against the given schema.

func ValidateLeafRefData

func ValidateLeafRefData(schema *yang.Entry, value interface{}, opt *LeafrefOptions) util.Errors

ValidateLeafRefData traverses the entire tree with root value and the given corresponding schema. For the referring node A, the leafref will point to a value set B which may be empty. For each element in B:

  • if the element is a leaf, it checks whether A == B
  • if the element is a leaf list C, it check whether A is equal to any of the elements of C.

It returns nil if at least one equality check passes or an error otherwise. It also returns an error if any leafref points to a value outside of the tree rooted at value; therefore it should only be called on the root node of the entire data tree. The supplied LeafrefOptions specify particular behaviours of the leafref validation such as ignoring missing pointed to elements.

Types

type LeafrefOptions

type LeafrefOptions struct {
	// IgnoreMissingData determines whether leafrefs that target a node
	// that does not exist should return an error to the calling application. When
	// set to true, no error is returned.
	//
	// This functionality is typically used where a partial set of schema information
	// is populated, but validation is required - for example, configuration for
	// a protocol within OpenConfig references an interface, but the schema being
	// validated does not contain the interface definitions.
	IgnoreMissingData bool
}

LeafrefOptions controls the behaviour of validation functions for leaf-ref data types.

func (LeafrefOptions) IsValidationOption

func (LeafrefOptions) IsValidationOption()

IsValidationOption ensures that LeafrefOptions implements the ValidationOption interface.

Directories

Path Synopsis
Package validate is used for testing with the default OpenConfig generated structs.
Package validate is used for testing with the default OpenConfig generated structs.

Jump to

Keyboard shortcuts

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