validator

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirectiveConfig

type DirectiveConfig struct {
	// directives that are allowed to be defined on objects
	AllowedObjectDirectives map[string]ObjectDirectiveValidationOptions
	// directives that are allowed to be defined on fields
	AllowedFieldDirectives map[string]FieldDirectiveOptions
}

type DirectiveValidator

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

func NewDirectiveValidator

func NewDirectiveValidator(
	config *DirectiveConfig,
) *DirectiveValidator

func (*DirectiveValidator) ValidateFieldDirective

func (v *DirectiveValidator) ValidateFieldDirective(
	directive *schema.Directive,
	objectDirectives []string,
	fieldType types.Comparable,
) error

func (*DirectiveValidator) ValidateObjectDirective

func (v *DirectiveValidator) ValidateObjectDirective(directive *schema.Directive) error

type FieldConfig

type FieldConfig struct {
	// list of allowed types representad as comparable structure
	AllowedTypes []types.Comparable
	// validation func that you can define to validate more complex scenarios like objects
	TypeValidator TypeValidationFunc
}

type FieldDirectiveOptions

type FieldDirectiveOptions struct {
	// list of field types that are allowed for this directive
	AllowedFieldType []types.Comparable
	// allow this directive on all field types
	AllowAllFieldTypes bool
	// list of required arguments and their kinds (use * to allow all kinds)
	RequiredArgumentKinds map[string]string
	// list of optional arguments and their kinds (use * to allow all kinds)
	OptionalArgumentKinds map[string]string
	// one of these directives in this list is required to be defined on the object
	RequireOneObjectDirectiveOf []string
	// all of these directives in this list are required to be defined on the object
	RequireAllObjectDirectivesOf []string
}

type FieldValidator

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

func NewFieldValidator

func NewFieldValidator(
	config *FieldConfig,
	directiveValidator FieldValidatorDirectiveValidator,
) *FieldValidator

func (*FieldValidator) Validate

func (v *FieldValidator) Validate(
	field *schema.Field,
	object *schema.Object,
	schema *schema.Schema,
	customScalarTypes []string,
) error

type FieldValidatorDirectiveValidator

type FieldValidatorDirectiveValidator interface {
	ValidateFieldDirective(directive *schema.Directive, objectDirectiveNames []string, fieldType types.Comparable) error
}

type MockDirectiveValidator

type MockDirectiveValidator struct {
	mock.Mock
}

func (*MockDirectiveValidator) ValidateFieldDirective

func (v *MockDirectiveValidator) ValidateFieldDirective(
	directive *schema.Directive,
	objectDirectiveNames []string,
	fieldType types.Comparable,
) error

func (*MockDirectiveValidator) ValidateObjectDirective

func (v *MockDirectiveValidator) ValidateObjectDirective(directive *schema.Directive) error

type MockFieldValidator

type MockFieldValidator struct {
	mock.Mock
}

func (*MockFieldValidator) Validate

func (v *MockFieldValidator) Validate(
	field *schema.Field,
	object *schema.Object,
	schema *schema.Schema,
	customScalarTypes []string,
) error

type MockObjectValidator

type MockObjectValidator struct {
	mock.Mock
}

func (*MockObjectValidator) Validate

func (v *MockObjectValidator) Validate(obj *schema.Object, customScalarTypes []string) error

type ObjectConfig

type ObjectConfig struct {
	// set to true if at least one directive is required
	RequireObjectDirective bool
}

type ObjectDirectiveValidationOptions

type ObjectDirectiveValidationOptions struct {
	// list of required arguments and their kinds (use * to allow all kinds)
	RequiredArgumentKinds map[string]string
	// list of optional arguments and their kinds (use * to allow all kinds)
	OptionalArgumentKinds map[string]string
}

type ObjectValidator

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

func NewObjectValidator

func NewObjectValidator(
	config *ObjectConfig,
	directiveValidator ObjectValidatorDirectiveValidator,
	fieldValidator ObjectValidatorFieldValidator,
) *ObjectValidator

func (*ObjectValidator) Validate

func (v *ObjectValidator) Validate(object *schema.Object, schema *schema.Schema, customScalarTypes []string) error

type ObjectValidatorDirectiveValidator

type ObjectValidatorDirectiveValidator interface {
	ValidateObjectDirective(directive *schema.Directive) error
	ValidateFieldDirective(directive *schema.Directive, objectDirectiveNames []string, fieldType types.Comparable) error
}

type ObjectValidatorFieldValidator

type ObjectValidatorFieldValidator interface {
	Validate(field *schema.Field, object *schema.Object, schema *schema.Schema, customScalarTypes []string) error
}

type TypeValidationFunc

type TypeValidationFunc func(field *schema.Field, object *schema.Object, schema *schema.Schema, customScalarTypes []string) error

Jump to

Keyboard shortcuts

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