extension PureYAML.Model.Value: PureYAML.Validation.Traversable { /// For a mapping: the mapping itself (a `Validation` fires on this), and each pair's /// key node at its own path (so a key-typed check can inspect it, e.g. "is this key a string"). /// Nothing extra for any other case. public var extraOffers: [(component: PureYAML.Validation.Path.Component?, value: any PureYAML.Validation.Validatable)] { guard case let .mapping(mapping) = self else { return [] } return [(nil, mapping)] + mapping.pairs.map { pair in (component: pair.keyNode.pathComponent, value: pair.keyNode) } } /// A mapping's children are its pairs' values, keyed by their key node's path component; a /// sequence's children are its values, keyed by index. A scalar has none. public var children: [(component: PureYAML.Validation.Path.Component, value: PureYAML.Model.Value)] { switch self { case let .mapping(mapping): mapping.pairs.map { pair in (component: pair.keyNode.pathComponent, value: pair.value) } case let .sequence(values): values.indices.map { index in (component: .index(index), value: values[index]) } case .null, .bool, .int, .double, .string: [] } } }