Documentation

Overview

    Package validation provides simple validation of goldi containers

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Constraint

    type Constraint interface {
    	Validate(*goldi.Container) error
    }

      A Constraint represents a certain criteria that a container needs to fulfill in order to be valid.

      type ContainerValidator

      type ContainerValidator struct {
      	Constraints []Constraint
      }

        The ContainerValidator can be used to determine whether a container passes a set of validation constraints.

        func NewContainerValidator

        func NewContainerValidator() *ContainerValidator

          NewContainerValidator creates a new ContainerValidator. The validator will be initialized with the NoInvalidTypesConstraint, TypeParametersConstraint and TypeReferencesConstraint

          func (*ContainerValidator) Add

          func (v *ContainerValidator) Add(constraint Constraint)

            Add another constraint to this validator

            func (*ContainerValidator) MustValidate

            func (v *ContainerValidator) MustValidate(container *goldi.Container)

              MustValidate behaves exactly as ContainerValidator.Validate but panics if an error occurs

              func (*ContainerValidator) Validate

              func (v *ContainerValidator) Validate(container *goldi.Container) (err error)

                Validate checks if the given container passes all constraints that are registered at the ContainerValidator.

                type NoInvalidTypesConstraint

                type NoInvalidTypesConstraint struct{}

                  The NoInvalidTypesConstraint checks all types that none of the registered types is invalid

                  func (*NoInvalidTypesConstraint) Validate

                  func (c *NoInvalidTypesConstraint) Validate(container *goldi.Container) (err error)

                    Validate implements the Constraint interface by checking if the given container does not contain invalid types.

                    type TypeParametersConstraint

                    type TypeParametersConstraint struct{}

                      The TypeParametersConstraint is used in a ContainerValidator to check if all used parameters do exist.

                      func (*TypeParametersConstraint) Validate

                      func (c *TypeParametersConstraint) Validate(container *goldi.Container) (err error)

                        Validate implements the Constraint interface by checking if all referenced parameters have been defined.

                        type TypeReferencesConstraint

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

                          The TypeReferencesConstraint is used in a ContainerValidator to check if all referenced types in the container have been defined.

                          func (*TypeReferencesConstraint) Validate

                          func (c *TypeReferencesConstraint) Validate(container *goldi.Container) (err error)

                            Validate implements the Constraint interface by checking if all referenced types have been defined.