Skip to content

Commit 1aa237a

Browse files
committed
feat: add nil validation rule
1 parent aa354c5 commit 1aa237a

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Validator
3+
// Copyright © 2025 Space Code. All rights reserved.
4+
//
5+
6+
import Foundation
7+
8+
/// A nil validation rule.
9+
public struct NilValidationRule<T>: IValidationRule {
10+
// MARK: Types
11+
12+
public typealias Input = T?
13+
14+
// MARK: Properties
15+
16+
/// The validation error.
17+
public let error: IValidationError
18+
19+
// MARK: Initialization
20+
21+
public init(error: IValidationError) {
22+
self.error = error
23+
}
24+
25+
// MARK: IValidationRule
26+
27+
public func validate(input: T?) -> Bool {
28+
input == nil
29+
}
30+
}

0 commit comments

Comments
 (0)