func InvalidKeysInMap(m *yaml.Node, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string {
	invalidKeys := make([]string, 0)
	if m == nil || m.Kind != yaml.MappingNode {
		return invalidKeys
	}
	for i := 0; i < len(m.Content); i += 2 {
		key := m.Content[i].Value
		found := false
		for _, allowedKey := range allowedKeys {
			if key == allowedKey {
				found = true
				break
			}
		}
		if !found {
			for _, allowedPattern := range allowedPatterns {
				if allowedPattern.MatchString(key) {
					found = true
					break
				}
			}
			if !found {
				invalidKeys = append(invalidKeys, key)
			}
		}
	}
	return invalidKeys
}
InvalidKeysInMap returns keys in a map that don't match a list of allowed keys and patterns.
package compiler
import (
	"fmt"
	"regexp"
	"sort"
	"strconv"
	"github.com/googleapis/gnostic/jsonschema"
	"gopkg.in/yaml.v3"
)
func UnpackMap(in *yaml.Node) (*yaml.Node, bool) {
	if in == nil {
		return nil, false
	}
	return in, true
}
func SortedKeysForMap(m *yaml.Node) []string {
	keys := make([]string, 0)
	if m.Kind == yaml.MappingNode {
		for i := 0; i < len(m.Content); i += 2 {
			keys = append(keys, m.Content[i].Value)
		}
	}
	sort.Strings(keys)
	return keys
}
func MapHasKey(m *yaml.Node, key string) bool {
	if m == nil {
		return false
	}
	if m.Kind == yaml.MappingNode {
		for i := 0; i < len(m.Content); i += 2 {
			itemKey := m.Content[i].Value
			if key == itemKey {
				return true
			}
		}
	}
	return false
}
func MapValueForKey(m *yaml.Node, key string) *yaml.Node {
	if m == nil {
		return nil
	}
	if m.Kind == yaml.MappingNode {
		for i := 0; i < len(m.Content); i += 2 {
			itemKey := m.Content[i].Value
			if key == itemKey {
				return m.Content[i+1]
			}
		}
	}
	return nil
}
func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string {
	stringArray := make([]string, 0)
	for _, item := range interfaceArray {
		v, ok := item.(string)
		if ok {
			stringArray = append(stringArray, v)
		}
	}
	return stringArray
}
func SequenceNodeForNode(node *yaml.Node) (*yaml.Node, bool) {
	if node.Kind != yaml.SequenceNode {
		return nil, false
	}
	return node, true
}
func BoolForScalarNode(node *yaml.Node) (bool, bool) {
	if node == nil {
		return false, false
	}
	if node.Kind == yaml.DocumentNode {
		return BoolForScalarNode(node.Content[0])
	}
	if node.Kind != yaml.ScalarNode {
		return false, false
	}
	if node.Tag != "!!bool" {
		return false, false
	}
	v, err := strconv.ParseBool(node.Value)
	if err != nil {
		return false, false
	}
	return v, true
}
func IntForScalarNode(node *yaml.Node) (int64, bool) {
	if node == nil {
		return 0, false
	}
	if node.Kind == yaml.DocumentNode {
		return IntForScalarNode(node.Content[0])
	}
	if node.Kind != yaml.ScalarNode {
		return 0, false
	}
	if node.Tag != "!!int" {
		return 0, false
	}
	v, err := strconv.ParseInt(node.Value, 10, 64)
	if err != nil {
		return 0, false
	}
	return v, true
}
func FloatForScalarNode(node *yaml.Node) (float64, bool) {
	if node == nil {
		return 0.0, false
	}
	if node.Kind == yaml.DocumentNode {
		return FloatForScalarNode(node.Content[0])
	}
	if node.Kind != yaml.ScalarNode {
		return 0.0, false
	}
	if (node.Tag != "!!int") && (node.Tag != "!!float") {
		return 0.0, false
	}
	v, err := strconv.ParseFloat(node.Value, 64)
	if err != nil {
		return 0.0, false
	}
	return v, true
}
func StringForScalarNode(node *yaml.Node) (string, bool) {
	if node == nil {
		return "", false
	}
	if node.Kind == yaml.DocumentNode {
		return StringForScalarNode(node.Content[0])
	}
	switch node.Kind {
	case yaml.ScalarNode:
		switch node.Tag {
		case "!!int":
			return node.Value, true
		case "!!str":
			return node.Value, true
		case "!!timestamp":
			return node.Value, true
		case "!!null":
			return "", true
		default:
			return "", false
		}
	default:
		return "", false
	}
}
func StringArrayForSequenceNode(node *yaml.Node) []string {
	stringArray := make([]string, 0)
	for _, item := range node.Content {
		v, ok := StringForScalarNode(item)
		if ok {
			stringArray = append(stringArray, v)
		}
	}
	return stringArray
}
func MissingKeysInMap(m *yaml.Node, requiredKeys []string) []string {
	missingKeys := make([]string, 0)
	for _, k := range requiredKeys {
		if !MapHasKey(m, k) {
			missingKeys = append(missingKeys, k)
		}
	}
	return missingKeys
}