Skip to content

Commit cb68dd2

Browse files
Merge tag '5.5.1' into develop
[ADD] `Equatable` conformance
2 parents 16a9aba + 0638abd commit cb68dd2

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

Sources/Core/0_Validatable/*SomeValidatable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
internal implementation.
3030
*/
3131
public
32-
protocol SomeValidatable
32+
protocol SomeValidatable: Equatable
3333
{
3434
func validate() throws
3535
}

Sources/Core/1_Entity/*SomeValidatableEntity.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ extension SomeValidatableEntity
4949
Returns list of all members that have to be involved in
5050
automatic entity validation.
5151
*/
52-
var allValidatableMembers: [SomeValidatable]
52+
var allValidatableMembers: [any SomeValidatable]
5353
{
5454
return allMembers
55-
.compactMap{ $0 as? SomeValidatable }
55+
.compactMap{ $0 as? (any SomeValidatable) }
5656
}
5757
}
5858

Sources/Core/2_ValueWrappers/*Persistence.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,28 @@ extension SomeStorageKey
4646
// MARK: - ValueStorage
4747

4848
public
49-
enum ValueStorage
49+
enum ValueStorage: Equatable
5050
{
5151
case appStorageStandard(key: SomeStorageKey)
5252
case appStorage(key: SomeStorageKey, storageName: String)
5353
//case keychain(key: SomeStorageKey)
54+
55+
public
56+
static
57+
func == (lhs: ValueStorage, rhs: ValueStorage) -> Bool
58+
{
59+
switch (lhs, rhs)
60+
{
61+
case (.appStorageStandard(let lhsKey), .appStorageStandard(let rhsKey)):
62+
return lhsKey.name == rhsKey.name
63+
64+
case (.appStorage(let lhsKey, let lhsStorageName), .appStorage(let rhsKey, let rhsStorageName)):
65+
return (lhsKey.name == rhsKey.name && lhsStorageName == rhsStorageName)
66+
67+
default:
68+
return false
69+
}
70+
}
5471
}
5572

5673
//---

Sources/Core/2_ValueWrappers/*SomeValidatableValueWrapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626

2727
public
28-
protocol SomeValidatableValueWrapper: Codable
28+
protocol SomeValidatableValueWrapper: Codable, Equatable
2929
{
3030
associatedtype Value: SomeValidatableValue
3131

Sources/Core/3_Value/*SomeValidatableValue.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ import XCERequirement
3232
Describes custom value type for a wrapper.
3333
*/
3434
public
35-
protocol SomeValidatableValue: DisplayNamed
35+
protocol SomeValidatableValue: DisplayNamed, Equatable
3636
{
37-
associatedtype Raw: Codable
37+
associatedtype Raw: Codable, Equatable
3838

39-
associatedtype Valid: Codable
39+
associatedtype Valid: Codable, Equatable
4040

4141
static
4242
var isSecret: Bool { get }

0 commit comments

Comments
 (0)