Skip to content

Commit

Permalink
Bump decoded (#1)
Browse files Browse the repository at this point in the history
* Bump decoded

* Tweak value access

* Move doc link
  • Loading branch information
siemensikkema authored Nov 22, 2021
1 parent 9402304 commit aba1336
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/siemensikkema/Decoded.git", from: "0.4.0")
.package(url: "https://github.com/siemensikkema/Decoded.git", from: "0.5.0")
],
targets: [
.target(
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

Type-safe and composable validations with versatile output.

See the [full documentation](https://validations.siemensikkema.nl).

# Installation

Add `Validations` to your `Package.swift` file.
Expand Down Expand Up @@ -35,3 +33,6 @@ Import `Decoded` and `Validations` to any file you want to use this library in.
import Decoded
import Validations
```

# Documentation
This library's documentation is created using [DocC](https://developer.apple.com/documentation/docc) and can be found [here](https://validations.siemensikkema.nl).
2 changes: 1 addition & 1 deletion Sources/Validations/KeyedSuccess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ extension KeyedSuccess {

extension Decoded {
var keyedSuccess: KeyedSuccess<T>? {
success.map { KeyedSuccess(codingPath: codingPath, success: $0) }
result.success.map { KeyedSuccess(codingPath: codingPath, success: $0) }
}
}
4 changes: 2 additions & 2 deletions Sources/Validations/Validator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public extension Validator {
validate: @escaping (KeyedSuccess<U>) -> ValidationFailure?
) {
self.init { decoded in
decoded.value?[keyPath: keyPath].keyedSuccess
decoded.flatMap(keyPath).keyedSuccess
} validate: { _, success in
validate(success)
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public extension Validator {
self.init { (decoded: Decoded<T>) in
let nested = decoded.flatMap(keyPath)

guard nested.success != nil else { return nil }
guard nested.result.success != nil else { return nil }

return validator(nested)
}
Expand Down

0 comments on commit aba1336

Please sign in to comment.