PureYAML/Sources/API.swift

22 lines
700 B
Swift

public extension PureYAML {
/// Parses a YAML document into a ``Model/Value`` tree.
static func parse(_ yaml: String) throws -> Model.Value {
try Parsing.Parser().parse(yaml)
}
/// Serializes a ``Model/Value`` tree into block-style YAML.
static func dump(_ value: Model.Value) -> String {
Emitting.Dumper().dump(value)
}
/// Validates a parsed YAML value with the default validation rules.
@discardableResult
static func validate(
_ value: Model.Value,
using validator: Validation.Validator = .init(),
strict: Bool = true,
) throws -> [Validation.Issue] {
try validator.validate(value, strict: strict)
}
}