-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from outfoxx/feature/yaml-schemas
Implement YAML schemas for properly reading and writing scalars
- Loading branch information
Showing
13 changed files
with
341 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Pattern.swift | ||
// PotentCodables | ||
// | ||
// Copyright © 2019 Outfox, inc. | ||
// | ||
// | ||
// Distributed under the MIT License, See LICENSE for details. | ||
// | ||
|
||
import Foundation | ||
import Regex | ||
|
||
|
||
extension Regex: ExpressibleByStringLiteral { | ||
|
||
public init(stringLiteral value: StaticString) { | ||
self.init(value) | ||
} | ||
|
||
} | ||
|
||
extension Regex { | ||
|
||
public static func anyOf(_ regexes: Regex...) -> Regex { | ||
do { | ||
return try Regex(string: regexes.map { "(\($0.description))" }.joined(separator: "|")) | ||
} | ||
catch { | ||
preconditionFailure("unexpected error creating regex from joined set: \(error)") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.