We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 37278bc commit c34cc2eCopy full SHA for c34cc2e
1 file changed
Sources/ValidatorCore/Classes/Rules/CharactersValidationRule.swift
@@ -0,0 +1,33 @@
1
+//
2
+// Validator
3
+// Copyright © 2025 Space Code. All rights reserved.
4
5
+
6
+import Foundation
7
8
+/// A characters validation rule.
9
+public struct CharactersValidationRule: IValidationRule {
10
+ // MARK: Types
11
12
+ public typealias Input = String
13
14
+ // MARK: Properties
15
16
+ public let characterSet: CharacterSet
17
18
+ /// The validation error.
19
+ public let error: IValidationError
20
21
+ // MARK: Initialization
22
23
+ public init(characterSet: CharacterSet, error: IValidationError) {
24
+ self.characterSet = characterSet
25
+ self.error = error
26
+ }
27
28
+ // MARK: IValidationRule
29
30
+ public func validate(input: String) -> Bool {
31
+ input.rangeOfCharacter(from: characterSet.inverted) == .none
32
33
+}
0 commit comments