public extension PureYAML.Validation { /// The caseless namespace of built-in type-directed checks, referenceable by name. enum BuiltinCheck { /// Reports each duplicate key within a single mapping. The type-directed counterpart of the /// legacy `Rule.mappingKeysAreUnique`; fires on `Model.Mapping` values directly rather than /// switching on a `Model.Value`. public static var mappingKeysAreUnique: Check { Check(description: "Mapping keys are unique") { context in var seen = Set() var issues: [Issue] = [] for pair in context.subject.pairs where !seen.insert(pair.keyNode).inserted { issues.append(Issue( severity: .error, reason: "Duplicate mapping key '\(pair.keyNode.description)'", path: context.path.appending(pair.keyNode.pathComponent), )) } return issues } } } }