validation

package
v0.396.8 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Validator

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

func NewValidator

func NewValidator(asts []*parser.AST) *Validator

func (*Validator) RunAllValidators

func (v *Validator) RunAllValidators(withWarnings bool) (errs *errorhandling.ValidationErrors)

RunAllValidators will run all the validators available. If withWarnings is true, it will return the errors even if they contain just warnings

type Visitor

type Visitor struct {
	EnterModel func(n *parser.ModelNode)
	LeaveModel func(n *parser.ModelNode)

	EnterModelSection func(n *parser.ModelSectionNode)
	LeaveModelSection func(n *parser.ModelSectionNode)

	EnterMessage func(n *parser.MessageNode)
	LeaveMessage func(n *parser.MessageNode)

	EnterField func(n *parser.FieldNode)
	LeaveField func(n *parser.FieldNode)

	EnterAction func(n *parser.ActionNode)
	LeaveAction func(n *parser.ActionNode)

	EnterWith func(n *parser.ActionNode)
	LeaveWith func(n *parser.ActionNode)

	EnterActionInput func(n *parser.ActionInputNode)
	LeaveActionInput func(n *parser.ActionInputNode)

	EnterEnum func(n *parser.EnumNode)
	LeaveEnum func(n *parser.EnumNode)

	EnterRole func(n *parser.RoleNode)
	LeaveRole func(n *parser.RoleNode)

	EnterAttribute func(n *parser.AttributeNode)
	LeaveAttribute func(n *parser.AttributeNode)

	EnterAttributeArgument func(n *parser.AttributeArgumentNode)
	LeaveAttributeArgument func(n *parser.AttributeArgumentNode)

	EnterAPI func(n *parser.APINode)
	LeaveAPI func(n *parser.APINode)

	EnterAPIModel func(n *parser.APIModelNode)
	LeaveAPIModel func(n *parser.APIModelNode)

	EnterAPIModelAction func(n *parser.APIModelActionNode)
	LeaveAPIModelAction func(n *parser.APIModelActionNode)

	EnterJob func(n *parser.JobNode)
	LeaveJob func(n *parser.JobNode)

	EnterJobInput func(n *parser.JobInputNode)
	LeaveJobInput func(n *parser.JobInputNode)
}

Visitor lets you define "enter" and "leave" functions for AST nodes. This struct may not have fields for all AST nodes, so if you need to visit a node that is not currently supported add the necessary fields to this struct. For your functions to get called you must name these fields correctly.

For a node type called "SomethingNode" the hooks would be:

EnterSomething: func(n *parser.SomethingNode)
LeaveSomething: func(n *parser.SomethingNode)

func ApiModelActions added in v0.377.0

func ApiModelActions(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func CasingRule

func CasingRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

Casing checks that entities in the schema conform to our casing conventions.

Models, enums, enum values, roles, and API's must written in UpperCamelCase. Fields, actions, and inputs must be written in lowerCamelCase.

func ConflictingInputsRule

func ConflictingInputsRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

ConflictingInputsRule checks for model inputs that are also used in @set or @where attributes. In this case one usage would cancel out the other, so it doesn't make sense to have both.

For example in the getThing operation `id` is listed as a model input but is also used in a @where expression.

func CreateNestedInputIsMany added in v0.369.1

func CreateNestedInputIsMany(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func DuplicateActionNames added in v0.379.1

func DuplicateActionNames(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func DuplicateEnumNames added in v0.379.1

func DuplicateEnumNames(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func DuplicateInputsRule

func DuplicateInputsRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

DuplicateInputsRule checks that input names are not duplicated for an action.

func DuplicateJobNames added in v0.379.1

func DuplicateJobNames(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func DuplicateMessageNames added in v0.379.1

func DuplicateMessageNames(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func DuplicateModelNames added in v0.379.1

func DuplicateModelNames(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func EmbedAttributeRule added in v0.388.0

func EmbedAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func FunctionDisallowedBehavioursRule

func FunctionDisallowedBehavioursRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

FunctionDisallowedBehavioursRule will validate against usages of @set, @where and nested inputs for any actions marked with the @function attribute as we do not support these sets of functionality in @function's

func InvalidWithUsage

func InvalidWithUsage(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

InvalidWithUsage checks that the 'with' keyword is only used for actions that receive write values

func Jobs

func Jobs(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func MessagesRule added in v0.374.0

func MessagesRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func NameClashesRule

func NameClashesRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

NameClashes checks that the names of entities defined in a schema do not clash with built-in types or reserved keywords

func NotMutableInputs added in v0.370.1

func NotMutableInputs(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

NotMutableInputs checks that the write action inputs for update and create aren't setting the id of the root model and aren't setting the createdAt and updatedAt fields on any models.

func OnAttributeRule

func OnAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func OrderByAttributeRule

func OrderByAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func PermissionsAttributeArguments added in v0.370.1

func PermissionsAttributeArguments(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func RecursiveFieldsRule added in v0.374.0

func RecursiveFieldsRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func RelationshipsRules added in v0.369.1

func RelationshipsRules(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func RequiredFieldOfSameModelType

func RequiredFieldOfSameModelType(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

RequiredFieldOfSameModelType ensures that a model cannot have a required field of the same type, as this results in an infinite recursion.

func ScheduleAttributeRule

func ScheduleAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func SetAttributeExpressionRules added in v0.370.1

func SetAttributeExpressionRules(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func SortableAttributeRule

func SortableAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func StudioFeatures added in v0.386.1

func StudioFeatures(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

func UniqueAttributeRule

func UniqueAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

UniqueAttributeRule validates that unique attributes are valid according to the following rules: - @unique can't be used on Timestamp fields - @unique can't be used on has-many relations - @unique can't be used on array fields - composite @unique attributes must not have duplicate field names - composite @unique can't specify has-many fields

func UniqueLookup added in v0.370.0

func UniqueLookup(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

UniqueLookup checks that the filters will guarantee that one or zero record returned for get, update and delete actions

func UnusedInputRule

func UnusedInputRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor

UnusedInputRule checks that all named action inputs are used in either @set or @where expressions in the action.

type VisitorFunc

type VisitorFunc func([]*parser.AST, *errorhandling.ValidationErrors) Visitor

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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