Documentation ¶
Index ¶
- Variables
- type Validator
- type Visitor
- func AttributeArgumentsRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func CasingRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func ConflictingInputsRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func CreateNestedInputIsMany(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func DuplicateDefinitionRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func DuplicateInputsRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func FunctionDisallowedBehavioursRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func InvalidWithUsage(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func Jobs(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func NameClashesRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func OnAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func OrderByAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func RelationshipsRules(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func RepeatedScalarFieldRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func RequiredFieldOfSameMessageType(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func RequiredFieldOfSameModelType(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func ScheduleAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func SortableAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func UniqueAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- func UnusedInputRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
- type VisitorFunc
Constants ¶
This section is empty.
Variables ¶
var (
ValidActionTypes = []string{parser.ActionTypeCreate, parser.ActionTypeUpdate}
)
Functions ¶
This section is empty.
Types ¶
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func NewValidator ¶
func (*Validator) RunAllValidators ¶
func (v *Validator) RunAllValidators() (errs *errorhandling.ValidationErrors)
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) 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 AttributeArgumentsRule ¶
func AttributeArgumentsRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
Validates the arguments to any attribute expression.
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 DuplicateDefinitionRule ¶
func DuplicateDefinitionRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
DuplicateDefinitionRule checks the uniqueness of model, enum and message names.
Model, enum, and message names need to be globally unique.
func DuplicateInputsRule ¶
func DuplicateInputsRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
DuplicateInputsRule checks that input names are not duplicated for an action.
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 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 OnAttributeRule ¶
func OnAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
func OrderByAttributeRule ¶
func OrderByAttributeRule(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
func RelationshipsRules ¶ added in v0.369.1
func RelationshipsRules(asts []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
func RepeatedScalarFieldRule ¶
func RepeatedScalarFieldRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
RepeatedScalarFieldRule validates that you cannot define a repeated scalar field This will be temporary until we can support repeated fields at the database level
func RequiredFieldOfSameMessageType ¶
func RequiredFieldOfSameMessageType(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visitor
RequiredFieldOfSameMessageType ensures that a message cannot have a required field of the same type, as this results in an infinite recursion.
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 SortableAttributeRule ¶
func SortableAttributeRule(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 - composite @unique attributes must not have duplicate field names - composite @unique can't specify has-many fields
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
Source Files ¶
- attribute_arguments.go
- casing.go
- conflicting_inputs.go
- create_nested_input_is_many.go
- duplicate_definition.go
- duplicate_inputs.go
- function_attribute_disallowed_attributes.go
- invalid_with_usage.go
- jobs.go
- name_clashes.go
- on_attribute.go
- orderby_attribute.go
- relationships.go
- repeated_scalar_fields.go
- required_field_of_same_message_type.go
- required_field_of_same_model_type.go
- schedule_attribute.go
- sortable_attribute.go
- unique_attribute.go
- unused_inputs.go
- validation.go
- visitor.go