code: func ScalarLeafsRule(context *ValidationContext) *ValidationRuleInstance {
  
  	visitorOpts := &visitor.VisitorOptions{
  		KindFuncMap: map[string]visitor.NamedVisitFuncs{
  			kinds.Field: {
  				Kind: func(p visitor.VisitFuncParams) (string, interface{}) {
  					if node, ok := p.Node.(*ast.Field); ok && node != nil {
  						nodeName := ""
  						if node.Name != nil {
  							nodeName = node.Name.Value
  						}
  						ttype := context.Type()
  						if ttype != nil {
  							if IsLeafType(ttype) {
  								if node.SelectionSet != nil {
  									reportError(
  										context,
  										fmt.Sprintf(`Field "%v" of type "%v" must not have a sub selection.`, nodeName, ttype),
  										[]ast.Node{node.SelectionSet},
  									)
  								}
  							} else if node.SelectionSet == nil {
  								reportError(
  									context,
  									fmt.Sprintf(`Field "%v" of type "%v" must have a sub selection.`, nodeName, ttype),
  									[]ast.Node{node},
  								)
  							}
  						}
  					}
  					return visitor.ActionNoChange, nil
  				},
  			},
  		},
  	}
  	return &ValidationRuleInstance{
  		VisitorOpts: visitorOpts,
  	}
  }
docs: // ScalarLeafsRule Scalar leafs
  //
  // A GraphQL document is valid only if all leaf fields (fields without
  // sub selections) are of scalar or enum types.