Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-housh/swift-validations
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.3.1
Choose a base ref
...
head repository: m-housh/swift-validations
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 13 commits
  • 17 files changed
  • 2 contributors

Commits on Feb 6, 2023

  1. Documentation fixes.

    m-housh committed Feb 6, 2023
    Copy the full SHA
    4110b19 View commit details

Commits on Feb 7, 2023

  1. Copy the full SHA
    6ed6ddd View commit details
  2. Run swift-format

    m-housh authored and github-actions[bot] committed Feb 7, 2023
    Copy the full SHA
    e1e7a72 View commit details
  3. Fixed README.

    m-housh committed Feb 7, 2023
    Copy the full SHA
    4f6a057 View commit details
  4. Added support for error labels that are raw-representable strings or …

    …custom string convertible.
    m-housh committed Feb 7, 2023
    Copy the full SHA
    e9b6b5e View commit details

Commits on Feb 20, 2024

  1. feature: Updates dependencies, needs work to use CaseKeyPaths, but wo…

    …rks with old style case paths
    m-housh committed Feb 20, 2024
    Copy the full SHA
    b876f18 View commit details
  2. Run swift-format

    m-housh authored and github-actions[bot] committed Feb 20, 2024
    Copy the full SHA
    ac82ac9 View commit details
  3. feat: updtes dependencies

    m-housh committed Feb 20, 2024
    Copy the full SHA
    f6bf08c View commit details
  4. Updates macOS version for ci tests

    m-housh committed Feb 20, 2024
    Copy the full SHA
    78edd20 View commit details
  5. Removes unused macro from tests

    m-housh committed Feb 20, 2024
    Copy the full SHA
    565aa4e View commit details
  6. Adds skip macro validation flag

    m-housh committed Feb 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    56542a7 View commit details
  7. Fixed typo in spi.yml

    m-housh committed Feb 20, 2024
    Copy the full SHA
    ff88953 View commit details
  8. Merge pull request #1 from m-housh/0.3.3rc

    0.3.3rc
    m-housh authored Feb 20, 2024
    Copy the full SHA
    572e286 View commit details
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -8,10 +8,10 @@ on:
jobs:
mac:
name: macOS
runs-on: macOS-12
runs-on: macOS-13
strategy:
matrix:
xcode: ['14.2']
xcode: ['15.0']
config: ['debug']
steps:
- uses: actions/checkout@v3
@@ -28,7 +28,7 @@ jobs:
steps:
- uses: swift-actions/setup-swift@v1
with:
swift-version: 5.7
swift-version: 5.9
- uses: actions/checkout@v3
- name: Run Tests
run: make DOCKER_PLATFORM=linux/amd64 test-linux
80 changes: 40 additions & 40 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# Build and deploy DocC to GitHub pages. Based off of @karwa's work here:
# https://github.com/karwa/swift-url/blob/main/.github/workflows/docs.yml
name: Documentation

on:
release:
types:
- published
push:
branches:
- main
workflow_dispatch:

concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true

# Sets permissions to allow deployment to Github Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build DocC
run: make build-documentation
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: 'docs'
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v1

# name: Documentation
#
# on:
# release:
# types:
# - published
# push:
# branches:
# - main
# workflow_dispatch:
#
# concurrency:
# group: docs-${{ github.ref }}
# cancel-in-progress: true
#
# # Sets permissions to allow deployment to Github Pages
# permissions:
# contents: read
# pages: write
# id-token: write
#
# jobs:
# deploy:
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
# runs-on: macos-12
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Build DocC
# run: make build-documentation
# - name: Upload artifact
# uses: actions/upload-pages-artifact@v1
# with:
# path: 'docs'
# - name: Deploy to Github Pages
# id: deployment
# uses: actions/deploy-pages@v1
#
2 changes: 1 addition & 1 deletion .spi.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 1
builder:
confits:
confitg:
- platfrom: ios
scheme: swift-validations
- platform: macos-xcodebuild
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst
PLATFORM_TVOS = tvOS Simulator,name=Apple TV
PLATFORM_WATCHOS = watchOS Simulator,name=Apple Watch Series 7 (45mm)
CONFIG := debug
SWIFT_VERSION = 5.7
SWIFT_VERSION = 5.9
DOCKER_PLATFORM := linux/arm64

default: test-swift
@@ -16,14 +16,15 @@ test-linux:
--platform "$(DOCKER_PLATFORM)" \
swift:"$(SWIFT_VERSION)-focal" \
swift test

test-swift:
swift test

test-library:
for platform in "$(PLATFORM_IOS)" "$(PLATFORM_MACOS)" "$(PLATFORM_MAC_CATALYST)" "${PLATFORM_TVOS}" "${PLATFORM_WATCHOS}"; do \
xcodebuild test \
-configuration $(CONFIG) \
-skipMacroValidation \
-workspace .swiftpm/xcode/package.xcworkspace \
-scheme swift-validations \
-destination platform="$$platform" || exit 1; \
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.7
// swift-tools-version: 5.9

import PackageDescription

@@ -9,9 +9,9 @@ let package = Package(
.library(name: "Validations", targets: ["Validations"])
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-case-paths.git", from: "0.4.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "0.6.1"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay.git", from: "0.8.0"),
.package(url: "https://github.com/pointfreeco/swift-case-paths.git", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"),
],
targets: [
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# swift-validation-builder
# swift-validations

[![CI](https://github.com/m-housh/swift-validations/actions/workflows/ci.yml/badge.svg)](https://github.com/m-housh/swift-validations/actions/workflows/ci.yml)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%m-housh%2Fswift-validations%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/m-housh/swift-validations)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%m-housh%2Fswift-validations%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/m-housh/swift-validations)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fm-housh%2Fswift-validations%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/m-housh/swift-validations)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fm-housh%2Fswift-validations%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/m-housh/swift-validations)

A swift package for creating validations, using `ResultBuilder` syntax.

5 changes: 4 additions & 1 deletion Sources/Validations/Documentation.docc/AsyncValidator.md
Original file line number Diff line number Diff line change
@@ -28,7 +28,10 @@ This file arranges the static methods on the `AsyncValidator` type for richer do
### Equatable Validators

- ``AsyncValidator/equals(_:)``
- ``AsyncValidator/equals(_:_:)``
- ``AsyncValidator/equals(_:_:)-54hr``
- ``AsyncValidator/equals(_:_:)-8afgd``
- ``AsyncValidator/equals(_:_:)-8cnq9``
- ``AsyncValidator/equals(_:_:)-4ax2h``

### Bool Validators

5 changes: 4 additions & 1 deletion Sources/Validations/Documentation.docc/Validator.md
Original file line number Diff line number Diff line change
@@ -28,7 +28,10 @@ This file arranges the static methods on the `Validator` type for richer documen
### Equatable Validators

- ``Validator/equals(_:)``
- ``Validator/equals(_:_:)``
- ``Validator/equals(_:_:)-295k2``
- ``Validator/equals(_:_:)-4abt0``
- ``Validator/equals(_:_:)-7xahg``
- ``Validator/equals(_:_:)-89itd``

### Bool Validators

12 changes: 11 additions & 1 deletion Sources/Validations/ValidationError.swift
Original file line number Diff line number Diff line change
@@ -105,6 +105,12 @@ extension ValidationError: CustomDebugStringConvertible {
// sorts unlabeled errors to the top.
return .manyFailed(
errors.flatMap(flatten())
.compactMap {
// remove wrapped errors that don't have a debug description.
($0.error as CustomDebugStringConvertible).debugDescription == ""
? nil
: $0
}
.sorted { $0.depth < $1.depth }
.map { $0.error },
context
@@ -158,7 +164,11 @@ extension ValidationError: CustomDebugStringConvertible {
var errors = errors[...]
while let error = errors.popFirst() {
guard case let .some((label, context)) = isFailed(error) else {
append("\(formatError(error))")
let formatted = formatError(error)
guard !formatted.isEmpty else {
continue
}
append(formatted)
continue
}
append(format(label: label, context: context))
16 changes: 8 additions & 8 deletions Sources/Validations/Validators/Case.swift
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ extension Validators {
public struct CaseValidator<Parent, Child, ChildValidator> {

/// The case path to use to access the child value.
public let casePath: CasePath<Parent, Child>
public let casePath: AnyCasePath<Parent, Child>

/// The validator to use when we found a child value in the case path.
public let validator: ChildValidator
@@ -58,7 +58,7 @@ extension Validators {
///
@inlinable
public init(
_ casePath: CasePath<Parent, Child>,
_ casePath: AnyCasePath<Parent, Child>,
using validator: ChildValidator,
file: StaticString = #file,
fileID: StaticString = #fileID,
@@ -88,7 +88,7 @@ extension Validator {
///
@inlinable
public static func `case`<ChildValidator: Validation>(
_ casePath: CasePath<Self.Value, ChildValidator.Value>,
_ casePath: AnyCasePath<Self.Value, ChildValidator.Value>,
with validator: ChildValidator,
file: StaticString = #file,
fileID: StaticString = #fileID,
@@ -119,7 +119,7 @@ extension Validator {
///
@inlinable
public static func `case`<Child>(
_ casePath: CasePath<Self.Value, Child>,
_ casePath: AnyCasePath<Self.Value, Child>,
with validator: Validator<Child>,
file: StaticString = #file,
fileID: StaticString = #fileID,
@@ -149,7 +149,7 @@ extension Validator {
/// - validator: The ``Validation`` to use for the embedded value.
@inlinable
public static func `case`<ChildValidator: Validation>(
_ casePath: CasePath<Self.Value, ChildValidator.Value>,
_ casePath: AnyCasePath<Self.Value, ChildValidator.Value>,
file: StaticString = #file,
fileID: StaticString = #fileID,
line: UInt = #line,
@@ -174,7 +174,7 @@ extension AsyncValidator {
///
@inlinable
public static func `case`<ChildValidator: AsyncValidation>(
_ casePath: CasePath<Self.Value, ChildValidator.Value>,
_ casePath: AnyCasePath<Self.Value, ChildValidator.Value>,
with validator: ChildValidator,
file: StaticString = #file,
fileID: StaticString = #fileID,
@@ -205,7 +205,7 @@ extension AsyncValidator {
///
@inlinable
public static func `case`<Child>(
_ casePath: CasePath<Self.Value, Child>,
_ casePath: AnyCasePath<Self.Value, Child>,
with validator: AsyncValidator<Child>,
file: StaticString = #file,
fileID: StaticString = #fileID,
@@ -235,7 +235,7 @@ extension AsyncValidator {
/// - validator: The ``AsyncValidation`` to use for the embedded value.
@inlinable
public static func `case`<ChildValidator: AsyncValidation>(
_ casePath: CasePath<Self.Value, ChildValidator.Value>,
_ casePath: AnyCasePath<Self.Value, ChildValidator.Value>,
file: StaticString = #file,
fileID: StaticString = #fileID,
line: UInt = #line,
Loading